1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.core.issue;
15
16 import ch.qos.logback.core.contention.RunnableWithCounterAndDone;
17 import ch.qos.logback.core.contention.ThreadedThroughputCalculator;
18 import ch.qos.logback.core.issue.SelectiveLockRunnable.LockingModel;
19
20
21
22
23
24
25
26 public class NoLockThroughput {
27
28 static int THREAD_COUNT = 3;
29 static long OVERALL_DURATION_IN_MILLIS = 2000;
30
31 public static void main(String args[]) throws InterruptedException {
32
33 ThreadedThroughputCalculator tp = new ThreadedThroughputCalculator(OVERALL_DURATION_IN_MILLIS);
34 tp.printEnvironmentInfo("NoLockThroughput");
35
36 for (int i = 0; i < 2; i++) {
37 tp.execute(buildArray(LockingModel.NOLOCK));
38 }
39
40 RunnableWithCounterAndDone[] runnableArray = buildArray(LockingModel.NOLOCK);
41 tp.execute(runnableArray);
42 tp.printThroughput(runnableArray,"No lock: ", true);
43 }
44
45 static SelectiveLockRunnable[] buildArray(LockingModel model) {
46 SelectiveLockRunnable[] array = new SelectiveLockRunnable[THREAD_COUNT];
47 for (int i = 0; i < THREAD_COUNT; i++) {
48 array[i] = new SelectiveLockRunnable(model);
49 }
50 return array;
51 }
52
53 }