forked from dyu/ffi-overhead
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hello.cpp
36 lines (28 loc) · 650 Bytes
/
hello.cpp
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
29
30
31
32
33
34
35
36
extern "C" {
#include <stdio.h>
#include "newplus/plus.h"
}
#include <string>
void run(int count)
{
long long start = current_timestamp();
int x = 0;
while (x < count)
x = plusone(x);
printf("%lld\n", current_timestamp() - start);
}
int main(int argc, char** argv)
{
if (argc == 1) {
printf("First arg (0 - 2000000000) is required.\n");
return 1;
}
int count = std::stoi(argv[1]);
if (count <= 0 || count > 2000000000) {
printf("Must be a positive number not exceeding 2 billion.\n");
return 1;
}
// start immediately
run(count);
return 0;
}