This repository has been archived by the owner on Mar 17, 2021. It is now read-only.
forked from tbaum/PerformanceRegressionTest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.java
147 lines (123 loc) · 6.22 KB
/
Main.java
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/**
* Copyright (c) 2002-2011 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Neo4j is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.bench.regression.main;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.neo4j.bench.cases.mixedload.MixedLoadBenchCase;
import org.neo4j.bench.cases.mixedload.Stats;
import org.neo4j.bench.chart.GenerateOpsPerSecChart;
import org.neo4j.helpers.Args;
import org.neo4j.jmx.Kernel;
import org.neo4j.kernel.Config;
import org.neo4j.kernel.EmbeddedGraphDatabase;
/* @SuppressWarnings( "restriction" ) // for the signal */
public class Main
{
public static void main( String[] args ) throws Exception
{
Args argz = new Args( args );
long timeToRun = Long.parseLong( argz.get( "time-to-run", "120" ) ); // Time in minutes
Map<String, String> props = new HashMap<String, String>();
props.put( Config.USE_MEMORY_MAPPED_BUFFERS, "true" );
final EmbeddedGraphDatabase db = new EmbeddedGraphDatabase( "db" );
final MixedLoadBenchCase myCase = new MixedLoadBenchCase( timeToRun );
/*
* Commented out because it breaks windows but it is nice to have for
* testing on real OSes
SignalHandler handler = new SignalHandler()
{
@Override
public void handle( Signal arg0 )
{
System.out.println( "Queued nodes currently : "
+ myCase.getNodeQueue().size() );
}
};
// SIGUSR1 is used by the JVM and INT, ABRT and friends
// are all defined for specific usage by POSIX. While SIGINT
// is conveniently issued by Ctrl-C, SIGUSR2 is for user defined
// behavior so this is what I use.
Signal signal = new Signal( "USR2" );
Signal.handle( signal, handler );
*/
myCase.run( db );
db.shutdown();
//
// Handle test results
//
double[] results = myCase.getResults();
String statsFileName = argz.get(GenerateOpsPerSecChart.OPS_PER_SECOND_FILE_ARG, "ops-per-second");
String chartFilename = argz.get( GenerateOpsPerSecChart.CHART_FILE_ARG, "chart.png" );
double threshold = Double.parseDouble( argz.get( "threshold", "0.05" ) );
String neoVersion = argz.get( "neo4j-version", "N/A" );
<<<<<<< HEAD
appendNewStatsToFile(results, statsFileName, neoVersion);
GenerateOpsPerSecChart aggregator = new GenerateOpsPerSecChart(statsFileName, chartFilename, threshold );
=======
boolean onlyCompareToGAReleases = Boolean.parseBoolean( argz.get( "only-compare-to-ga", "true" ) ); /* Compare performance only to GA releases */
appendNewStatsToFile(results, statsFileName, neoVersion);
GenerateOpsPerSecChart aggregator = new GenerateOpsPerSecChart(statsFileName, chartFilename, threshold, onlyCompareToGAReleases );
>>>>>>> 92d75b6... Tests now optionally only compare latest run with GA releases, on by default.
aggregator.process();
aggregator.generateChart();
if(aggregator.performanceHasDegraded()) {
Stats trumpStats = aggregator.getTrumpingStats();
Stats currentStats = aggregator.getLatestStats();
double trumpReads = trumpStats.getAvgReadsPerSec();
double trumpWrites = trumpStats.getAvgWritePerSec();
double currentReads = currentStats.getAvgReadsPerSec();
double currentWrites = currentStats.getAvgWritePerSec();
System.out.println();
System.out.println("================ FAILURE ================");
System.out.println("Stastically significant performance degradation detected, see chart for comparison to older runs.");
System.out.println();
if(trumpReads > currentReads) {
System.out.println("Avg. read performance for " + trumpStats.getName() + " : " + trumpReads + " reads/second" );
System.out.println("Avg. read performance for " + currentStats.getName() + " (now) : " + currentReads + " reads/second" );
System.out.println();
}
if(trumpWrites > currentWrites) {
System.out.println("Avg. write performance for " + trumpStats.getName() + " : " + trumpWrites + " writes/second" );
System.out.println("Avg. write performance for " + currentStats.getName() + " (now) : " + currentWrites + " writes/second" );
System.out.println();
}
System.out.println("=========================================");
System.exit(1);
}
}
private static void appendNewStatsToFile(double[] results, String statsFileName, String neoVersion) throws FileNotFoundException {
Stats newStats = new Stats(
new SimpleDateFormat( "MM-dd HH:mm" ).format( new Date() ) + " [" + neoVersion + "]" );
newStats.setAvgReadsPerSec( results[0] );
newStats.setAvgWritePerSec( results[1] );
newStats.setPeakReadsPerSec( results[2] );
newStats.setPeakWritesPerSec( results[3] );
newStats.setSustainedReadsPerSec( results[4] );
newStats.setSustainedWritesPerSec( results[5] );
PrintStream opsPerSecOutFile = new PrintStream( new FileOutputStream(
statsFileName, true ) );
newStats.write( opsPerSecOutFile, true );
}
}