-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMemoryOnSubstringIterator.java.txt
46 lines (39 loc) · 1.27 KB
/
MemoryOnSubstringIterator.java.txt
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
37
38
39
40
41
42
43
44
45
46
import java.io.IOException;
public class MemoryOnSubstringIterator {
public static void main(String[] args) {
int i, j, stringLength, bufferSize;
int c1, c1min, c1max, c1step, c2, c2min, c2max, c2step, iterations;
long time;
String path;
IntArray string=null, suffixes=null;
Utils.initRandom();
// Parsing input
path=args[0];
stringLength=Integer.parseInt(args[1]);
iterations=Integer.parseInt(args[2]);
c1min=Integer.parseInt(args[3]);
c1max=Integer.parseInt(args[4]);
c1step=Integer.parseInt(args[5]);
c2min=Integer.parseInt(args[6]);
c2max=Integer.parseInt(args[7]);
c2step=Integer.parseInt(args[8]);
// Measuring
try { string=Utils.loadDNA(path,stringLength,1000); }
catch(IOException e) {
e.printStackTrace();
System.exit(1);
}
for (c1=c1min; c1<=c1max; c1+=c1step) {
for (c2=c2min; c2<=c2max; c2+=c2step) {
Suffixes.QUICKSORT_HEAPSORT_SCALE=c1;
Suffixes.STOP_QUICKSORT_AT_SIZE=c2;
suffixes = new IntArray(stringLength,Utils.log2(stringLength));
for (i=0; i<stringLength; i++) suffixes.push(i);
time=System.currentTimeMillis();
for (i=0; i<iterations; i++) Suffixes.sort(suffixes,string);
System.out.print(((double)(System.currentTimeMillis()-time))/iterations+" ");
}
System.out.println();
}
}
}