Skip to content
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

bias results due to cpu "spin up" #1

Open
richemslie opened this issue Mar 21, 2018 · 0 comments
Open

bias results due to cpu "spin up" #1

richemslie opened this issue Mar 21, 2018 · 0 comments

Comments

@richemslie
Copy link

richemslie commented Mar 21, 2018

Thanks for making this public, I was about to do the same thing. :)

First few tests do suffer from "spin up" time of cpu ). Adding (some crappy code) to perform a dummy while loop for a second will knock about 20% time off the initial results.
eg:

int main(void) {
    auto start = std::chrono::steady_clock::now();
    long total = 0;
    while (true) {
        auto later = std::chrono::steady_clock::now();
        if (later - start > std::chrono::milliseconds(1000)) {
            break;
        }

        total++;
    }
    printf("Starting\n");
    ...

On i7-6900K, ubuntu 17.10

Without spinup

Performance of std::chrono::steady_clock
Average time per call: 20.1 ns
Clock tick period: 1.0 ns
Measured resolution: 18.0 ns (median: 20.0 ns) (sigma: 8.7 ns) (average: 20.1 +/- 0.1 ns)

Performance of std::chrono::system_clock
Average time per call: 20.3 ns
Clock tick period: 1.0 ns
Measured resolution: 19.0 ns (median: 20.0 ns) (sigma: 17.1 ns) (average: 20.3 +/- 0.1 ns)

Performance of std::chrono::high_resolution_clock
Average time per call: 19.1 ns
Clock tick period: 1.0 ns
Measured resolution: 14.0 ns (median: 20.0 ns) (sigma: 18.1 ns) (average: 19.1 +/- 0.1 ns)

With spinup:

Performance of std::chrono::steady_clock
Average time per call: 16.1 ns
Clock tick period: 1.0 ns
Measured resolution: 15.0 ns (median: 16.0 ns) (sigma: 6.3 ns) (average: 16.1 +/- 0.1 ns)

Performance of std::chrono::system_clock
Average time per call: 16.3 ns
Clock tick period: 1.0 ns
Measured resolution: 15.0 ns (median: 16.0 ns) (sigma: 8.2 ns) (average: 16.3 +/- 0.1 ns)

Performance of std::chrono::high_resolution_clock
Average time per call: 16.3 ns
Clock tick period: 1.0 ns
Measured resolution: 15.0 ns (median: 16.0 ns) (sigma: 9.7 ns) (average: 16.3 +/- 0.1 ns)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant