forked from abacusmodeling/abacus-develop
-
Notifications
You must be signed in to change notification settings - Fork 141
Test: Configure performance tests for math libraries #3511
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
afd9207
add performace test of sphbes functions.
grysgreat adf3c99
Merge remote-tracking branch 'ghyx/performace_test' into performace_test
jieli-matrix d5eeb6c
fix benchmark cmake errors
jieli-matrix ef3b780
reslove conflicts
jieli-matrix ebdb5c4
add dependencies for docker
jieli-matrix ea439d1
update docs
jieli-matrix fbaefc8
add performance tests for sphbes
jieli-matrix ed80949
add google benchmark
jieli-matrix af5cc0c
rewrite benchmark tests in fixtures
jieli-matrix 5d35c57
disable internal testing in benchmark
jieli-matrix ca35da7
merge benchmark into integration test
jieli-matrix 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
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
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,72 @@ | ||
#include"../math_sphbes.h" | ||
#include<fstream> | ||
#include <benchmark/benchmark.h> | ||
#include <iostream> | ||
#include <cstring> | ||
#include <cmath> | ||
|
||
/************************************************ | ||
* performace test of class Sphbes | ||
***********************************************/ | ||
|
||
/** | ||
* Tested function: | ||
* - sphbesj | ||
* - Spherical_Bessel | ||
*/ | ||
|
||
class PerfSphbes : public benchmark::Fixture { | ||
public: | ||
const double q = 1; | ||
const int n = 1000; | ||
double stop = 1000.0; | ||
double dr = 0.0; | ||
double* rc, *rinf, *jc, *jinf; | ||
void SetUp(const benchmark::State& state){ | ||
const double rcut = state.range(0) + 0.5; | ||
rc = new double[n + 10]; | ||
rinf = new double[n + 10]; | ||
jc = new double[n + 10]; | ||
jinf = new double[n + 10]; | ||
|
||
// generate data points in (0, rcut] in log scale | ||
double rmin = 0.0001; | ||
double log_rmin = std::log(rmin); | ||
double log_rcut = std::log(rcut); | ||
dr = (log_rcut - log_rmin) / (n-1); | ||
memset(rc, 0, (n+10) * sizeof(double)); | ||
for (int i = 0; i < n; i++) | ||
rc[i] = std::exp(log_rmin + i * dr); | ||
|
||
// generate data points in [rcut, stop] in linear scale | ||
memset(rinf, 0, (n+10) * sizeof(double)); | ||
rinf[0] = rcut; | ||
dr = (stop - rcut) / (n-1); | ||
for (int i = 1; i < n; i++) | ||
rinf[i] += rinf[i-1] + dr; | ||
} | ||
void TearDown(const benchmark::State& state){ | ||
delete[] rc; | ||
delete[] rinf; | ||
delete[] jc; | ||
delete[] jinf; | ||
} | ||
}; | ||
|
||
BENCHMARK_DEFINE_F(PerfSphbes, BM_Spherical_Bessel)(benchmark::State& state) { | ||
for (auto _ : state) { | ||
ModuleBase::Sphbes::Spherical_Bessel(n, rc, q, state.range(0), jc); | ||
ModuleBase::Sphbes::Spherical_Bessel(n, rinf, q, state.range(0), jinf); | ||
} | ||
} | ||
|
||
BENCHMARK_DEFINE_F(PerfSphbes, BM_sphbesj)(benchmark::State& state) { | ||
for (auto _ : state) { | ||
ModuleBase::Sphbes::sphbesj(n, rc, q, state.range(0), jc); | ||
ModuleBase::Sphbes::sphbesj(n, rinf, q, state.range(0), jinf); | ||
} | ||
} | ||
|
||
BENCHMARK_REGISTER_F(PerfSphbes, BM_sphbesj)->DenseRange(0, 11, 1)->Unit(benchmark::kMicrosecond); | ||
BENCHMARK_REGISTER_F(PerfSphbes, BM_Spherical_Bessel)->DenseRange(0, 11, 1)->Unit(benchmark::kMicrosecond); | ||
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.
Uh oh!
There was an error while loading. Please reload this page.