forked from fredrikwidlund/libdynamic_benchmark
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVectorGrowJavaTrove.java
More file actions
34 lines (31 loc) · 1 KB
/
VectorGrowJavaTrove.java
File metadata and controls
34 lines (31 loc) · 1 KB
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
import gnu.trove.list.array.TLongArrayList;
public class VectorGrowJavaTrove {
public static void main(String args[]) {
int i, j = 0, n = Integer.parseInt(args[0]);
long[] m;
long t;
TLongArrayList v = new TLongArrayList();
m = new long[101];
t = System.nanoTime();
m[0] = 0;
try
{
for (i = 0; i < n; i += n / 100)
{
for (j = 0; j < n / 100; j ++)
{
v.add(j);
}
m[i / (n / 100) + 1] = System.nanoTime() - t;
}
}
catch (Exception e)
{
System.out.println("TLongArrayList add " + j);
System.exit(-1);
}
System.out.println("\"size\",\"time\"");
for (i = 0; i <= 100; i ++)
System.out.printf("%d,%f\n", i * (n / 100), (float) m[i] / 1000000000f);
}
}