Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
77 lines (63 loc) · 2.16 KB

File metadata and controls

77 lines (63 loc) · 2.16 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
70
71
72
73
74
75
76
77
import java.io.*;
import java.util.*;
import java.text.*;
import java.util.concurrent.*;
import java.util.zip.GZIPOutputStream;
public class Test
{
static int ThreadNum =1;
static int Duration = 300; // seconds; Program will exit after Duration of seconds.
static int ReferenceSize = 1024 * 10; // each reference object size;
static int CountDownSize = 1000 * 100;
static int EachRemoveSize = 1000 * 50; // remove # of elements each time.
public static void main(String[] args)
throws IOException
{
if (args.length > 0 ) {
Duration = Integer.parseInt(args[0]);
ThreadNum = Integer.parseInt(args[1]);
}
for(int i=0; i< ThreadNum; i++ ) {
LoadThread thread = new LoadThread();
thread.start();
}
}
}
class LoadThread extends Thread {
long timeZero = System.currentTimeMillis();
long finishedUnit = 0;
public LoadThread() {
}
public void run() {
AbstractQueue<String> q = new ArrayBlockingQueue<String>(Test.CountDownSize);
char[] srcArray =new char[Test.ReferenceSize];
String emptystr = new String(srcArray);
finishedUnit =0;
long prevTime = timeZero;
for (int i = 0;; i = i + 1) {
// Simulate object use to force promotion into OldGen and then GC
if (q.size() >= Test.CountDownSize) {
String strHuge_remove =null;
for (int j = 0; j < Test.EachRemoveSize; j++) {
strHuge_remove = q.remove();
}
finishedUnit ++;
// every 1000 removal is counted as 1 unit.
long curTime = System.currentTimeMillis();
long timeDiff = curTime - prevTime;
prevTime = curTime;
long totalTime = curTime - timeZero;
if (totalTime > Test.Duration * 1000){
System.exit(0);
}
Date dNow = new Date( );
SimpleDateFormat ft = new SimpleDateFormat ("yyyy-MM-dd hh:mm:ss.SSSSS");
System.out.println(ft.format(dNow) + " finished Units (1K) = " + finishedUnit );
}
srcArray = new char[Test.ReferenceSize];
emptystr = new String(srcArray);
String str = emptystr.replace('\0', 'a');
q.add(str);
}
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.