-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathhello.cs
29 lines (26 loc) · 817 Bytes
/
hello.cs
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
using System;
using System.Runtime.InteropServices;
class Newplus {
[DllImport("./newplus/libnewplus.so")]
public static extern long current_timestamp();
[DllImport("./newplus/libnewplus.so")]
public static extern int plusone(int x);
public static void Main(string[] args) {
if (args.Length < 1)
throw new ArgumentException("First arg (0 - 2000000000) is required.");
int iterations;
if (int.TryParse(args[0], out iterations)) {
if (iterations > 2000000000 || iterations < 0)
throw new ArgumentException("Must be a positive number not exceeding 2 billion.");
} else {
throw new ArgumentException("Not a number.");
}
var start = current_timestamp();
var x = 0;
while (x < iterations) {
x = plusone(x);
}
var end = current_timestamp();
Console.WriteLine(end - start);
}
}