forked from abacusmodeling/abacus-develop
-
Notifications
You must be signed in to change notification settings - Fork 141
Add performace test of sphbes functions. #3492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
#include"../math_sphbes.h" | ||
#include<fstream> | ||
#include <benchmark/benchmark.h> | ||
#include <iostream> | ||
#include <string> | ||
|
||
/************************************************ | ||
* performace test of class Integral | ||
***********************************************/ | ||
|
||
/** | ||
* Note: this performace test try to measure the CPU time | ||
* of the spherical Bessel produced by class Sphbes, | ||
* and the memory usage of these functions; | ||
* at 2024-1-14 | ||
* | ||
* Tested function: | ||
* - Spherical_Bessel. | ||
* - Spherical_Bessel_Roots | ||
* - overloading of Spherical_Bessel. This funnction sets sjp[i] to 1.0 when i < msh. | ||
* - sphbesj | ||
* - sphbes_zeros | ||
*/ | ||
|
||
|
||
int msh = 700; | ||
int l0 = 0; | ||
int l1 = 1; | ||
int l2 = 2; | ||
int l3 = 3; | ||
int l4 = 4; | ||
int l5 = 5; | ||
int l6 = 6; | ||
int l7 = 7; | ||
double q = 1.0; | ||
double *r = new double[msh]; | ||
double *jl = new double[msh]; | ||
double *djl = new double[msh]; | ||
|
||
double mean(const double* vect, const int totN) | ||
{ | ||
double meanv = 0.0; | ||
for (int i=0; i< totN; ++i) {meanv += vect[i]/totN;} | ||
return meanv; | ||
} | ||
|
||
|
||
|
||
|
||
// Below are the wapper functions which contain the function to measure performance | ||
void SphericalBessel_func(){ | ||
//int l = 0; | ||
ModuleBase::Sphbes::Spherical_Bessel(msh,r,q,l0,jl); | ||
} | ||
|
||
void dSpherical_Bessel_dx_func(){ | ||
int il=5; | ||
ModuleBase::Sphbes::dSpherical_Bessel_dx(msh,r,q,il,djl); | ||
} | ||
void SphericalBesselRoots_func(){ | ||
int i=7; | ||
int neign = 100; | ||
double *eign = new double[neign]; | ||
|
||
ModuleBase::Sphbes::Spherical_Bessel_Roots(neign,i,1.0e-12,eign,10.0); | ||
free(eign); | ||
|
||
} | ||
|
||
void Sphbesj_func(){ | ||
ModuleBase::Sphbes::sphbesj(3,0); | ||
} | ||
|
||
|
||
|
||
//Below are the test time functions | ||
static void SphericalBessel(benchmark::State& state) { | ||
for (auto _ : state) | ||
SphericalBessel_func(); | ||
} | ||
|
||
static void dSpherical_Bessel_dx(benchmark::State& state) { | ||
for (auto _ : state) | ||
dSpherical_Bessel_dx_func(); | ||
} | ||
|
||
static void SphericalBesselRoots(benchmark::State& state) { | ||
for (auto _ : state) | ||
SphericalBesselRoots_func(); | ||
} | ||
|
||
static void Sphbesj(benchmark::State& state) { | ||
for (auto _ : state) | ||
Sphbesj_func(); | ||
} | ||
|
||
|
||
//Add the test time functions into google benchmark | ||
BENCHMARK(SphericalBessel); | ||
BENCHMARK(dSpherical_Bessel_dx); | ||
BENCHMARK(SphericalBesselRoots); | ||
BENCHMARK(Sphbesj); | ||
BENCHMARK_MAIN(); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since googlebench relies on testing mechanism and googletest toolkit, please set
ENABLE_GOOGLEBENCH
as affiliated toBUILD_TESTING
.