File: clock.h

package info (click to toggle)
halide 19.0.0-6
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 55,096 kB
  • sloc: cpp: 286,920; ansic: 22,751; python: 5,821; makefile: 4,374; sh: 2,445; java: 1,549; javascript: 282; pascal: 212; xml: 127; asm: 9
file content (28 lines) | stat: -rw-r--r-- 790 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <chrono>
#include <iomanip>
#include <sstream>

std::string items_per_second(int N, double elapsed) {
    double ips = N * 1000 / elapsed;
    std::string postfix = "";
    if (ips >= 1e8) {
        ips /= 1e9;
        postfix = "G";
    } else if (ips >= 1e5) {
        ips /= 1e6;
        postfix = "M";
    } else if (ips >= 1e2) {
        ips /= 1e3;
        postfix = "k";
    }

    std::ostringstream sout;
    sout << std::setprecision(3) << ips << postfix << "(items/s)";
    return sout.str();
}

double current_time() {
    static auto start_time = std::chrono::system_clock::now().time_since_epoch();
    auto now = std::chrono::system_clock::now().time_since_epoch() - start_time;
    return std::chrono::duration_cast<std::chrono::microseconds>(now).count() / 1e3;
}