-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSortAndOutputThread_test.cpp
More file actions
69 lines (52 loc) · 1.65 KB
/
SortAndOutputThread_test.cpp
File metadata and controls
69 lines (52 loc) · 1.65 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <jvmti.h>
#include <jni.h>
#include <iostream>
#include "AllocationRecord.h"
#include "DeathRecord.h"
#include "MethodEntryRecord.h"
#include "MethodExitRecord.h"
#include "PointerUpdateRecord.h"
#include "RootRecord.h"
#include "main.h"
#include "SortAndOutputThread.h"
using namespace std;
int main(int argc, char** argv) {
JNIEnv* jni = new JNIEnv();
jvmtiEnv* jvmti = new jvmtiEnv();
Record** records;
int num_records = 5;
for(int i = 0; i < 256; i++) {
wantRecord[i] = 'a';
}
records = new Record*[num_records];
records[0] = new AllocationRecord(1, 1, 1, "FakeType", 1, 'A');
records[1] = new MethodEntryRecord(1, 1, 1);
records[2] = new RootRecord(1,1);
records[3] = new MethodExitRecord(1,1,1,1);
records[4] = new DeathRecord(1,1);
records[0]->setTime(0);
records[1]->setTime(1);
records[2]->setTime(1);
records[3]->setTime(2);
SortAndOutputThread* sortAndOutput = new SortAndOutputThread(jvmti, (std::ostream*)&cerr);
sortAndOutput->initialize(jvmti, jni);
sortAndOutput->doParallelSortAndOutput(records, num_records);
records = new Record*[num_records];
records[0] = new AllocationRecord(2, 2, 2, "FakeType2", 1, 'A');
records[1] = new MethodEntryRecord(1, 2, 1);
records[2] = new RootRecord(2,1);
records[3] = new MethodExitRecord(1, 2, 1, 1);
records[4] = new DeathRecord(2,4);
records[0]->setTime(2);
records[1]->setTime(3);
records[2]->setTime(3);
records[3]->setTime(4);
sortAndOutput->doParallelSortAndOutput(records, num_records);
while(sortAndOutput->getStatus() != WAITING) {
this_thread::yield();
}
delete jni;
delete jvmti;
delete sortAndOutput;
return 0;
}