1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.classic.issue.lbclassic36;
15
16 import ch.qos.logback.classic.issue.lbclassic36.SelectiveDateFormattingRunnable.FormattingModel;
17 import ch.qos.logback.core.contention.ThreadedThroughputCalculator;
18
19
20
21
22
23
24
25 public class DateFormattingThreadedThroughputCalculator {
26
27 static int THREAD_COUNT = 16;
28 static long OVERALL_DURATION_IN_MILLIS = 3000;
29
30 public static void main(String args[]) throws InterruptedException {
31
32 ThreadedThroughputCalculator tp = new ThreadedThroughputCalculator(OVERALL_DURATION_IN_MILLIS);
33 tp.printEnvironmentInfo("DateFormatting");
34
35 for (int i = 0; i < 2; i++) {
36 tp.execute(buildArray(FormattingModel.SDF));
37 tp.execute(buildArray(FormattingModel.JODA));
38 }
39
40 SelectiveDateFormattingRunnable[] runnnableArrayJODA = buildArray(FormattingModel.JODA);
41 tp.execute(runnnableArrayJODA);
42 tp.printThroughput(runnnableArrayJODA, "JODA: ");
43
44 SelectiveDateFormattingRunnable[] runnnableArraySDF = buildArray(FormattingModel.JODA);
45 tp.execute(runnnableArraySDF);
46 tp.printThroughput(runnnableArraySDF, "SDF: ");
47
48 }
49
50 static SelectiveDateFormattingRunnable[] buildArray(FormattingModel model) {
51 SelectiveDateFormattingRunnable[] array = new SelectiveDateFormattingRunnable[THREAD_COUNT];
52 for (int i = 0; i < THREAD_COUNT; i++) {
53 array[i] = new SelectiveDateFormattingRunnable(model);
54 }
55 return array;
56 }
57
58 }