-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathhello.d
More file actions
33 lines (26 loc) · 697 Bytes
/
Copy pathhello.d
File metadata and controls
33 lines (26 loc) · 697 Bytes
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
import core.stdc.stdio;
import core.stdc.stdlib;
extern (C) int plusone(int x);
extern (C) long current_timestamp();
void run(int count) {
auto start = current_timestamp();
int x = 0;
while (x < count) {
x = plusone(x);
}
printf("%d", current_timestamp() - start);
}
extern (C) int main(int argc, char** argv) {
if (argc == 1) {
printf("First arg (0 - 2000000000) is required.\n");
return 1;
}
int count = atoi(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;
}