Skip to content

Commit 37b50a4

Browse files
committed
Initial commit
0 parents  commit 37b50a4

File tree

14 files changed

+621
-0
lines changed

14 files changed

+621
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/.settings
2+
/target
3+
/.classpath
4+
/.project

LICENSE

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
The MIT License (MIT)
3+
4+
Java benchmark tool project
5+
Copyright (c) 2015, W4 Software
6+
7+
---
8+
9+
Permission is hereby granted, free of charge, to any person obtaining a copy
10+
of this software and associated documentation files (the "Software"), to deal
11+
in the Software without restriction, including without limitation the rights
12+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
copies of the Software, and to permit persons to whom the Software is
14+
furnished to do so, subject to the following conditions:
15+
16+
The above copyright notice and this permission notice shall be included in
17+
all copies or substantial portions of the Software.
18+
19+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
THE SOFTWARE.
26+
27+
---
28+
29+
L'autorisation est accord�e, gracieusement, � toute personne acqu�rant une copie de ce
30+
logiciel et des fichiers de documentation associ�s (le "Logiciel"), de commercialiser
31+
le Logiciel sans restriction, notamment les droits d'utiliser, de copier, de modifier,
32+
de fusionner, de publier, de distribuer, de sous-licencier et/ou de vendre des copies
33+
du Logiciel, ainsi que d'autoriser les personnes auxquelles le Logiciel est fourni � le
34+
faire, sous r�serve des conditions suivantes :
35+
36+
La d�claration de copyright ci-dessus et la pr�sente autorisation doivent �tre incluses
37+
dans toutes copies ou parties substantielles du Logiciel.
38+
39+
LE LOGICIEL EST FOURNI "TEL QUEL", SANS GARANTIE D'AUCUNE SORTE, EXPLICITE OU IMPLICITE,
40+
NOTAMMENT SANS GARANTIE DE QUALIT� MARCHANDE, D�AD�QUATION � UN USAGE PARTICULIER ET
41+
D'ABSENCE DE CONTREFA�ON. EN AUCUN CAS, LES AUTEURS OU TITULAIRES DU DROIT D'AUTEUR
42+
NE SERONT RESPONSABLES DE TOUT DOMMAGE, R�CLAMATION OU AUTRE RESPONSABILIT�, QUE CE SOIT
43+
DANS LE CADRE D'UN CONTRAT, D'UN D�LIT OU AUTRE, EN PROVENANCE DE, CONS�CUTIF � OU EN
44+
RELATION AVEC LE LOGICIEL OU SON UTILISATION, OU AVEC D'AUTRES �L�MENTS DU LOGICIEL.
45+
46+
---

README.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
Java Benchmark Tool
2+
===================
3+
4+
This tool is designed to benchmark the performance of the host it is running on. It will monitor the speed of CPU, RAM and disk.
5+
6+
7+
Download
8+
--------
9+
10+
The binary package is available from the [release page](https://github.com/w4software/misc-tool-benchmark/releases)
11+
12+
13+
The source package can be obtained either as a [zip archive] or using git
14+
15+
git clone https://github.com/w4software/misc-tool-benchmark
16+
17+
18+
Usage
19+
-----
20+
21+
To start the benchmark, run the following command
22+
23+
java -jar misc-tool-benchmark-1.0.jar [number of threads]
24+
25+
The parameter _number of threads_ is optional. If not provided, the benchmark
26+
will try to determine the number of real cpu cores instead of relying on the
27+
OS determined value that is a number of cpu threads (that may be different when hyperthreading-like features are in enabled).
28+
29+
As a starter, you may want to begin with a _number of thread_ of __1__ before
30+
trying to test performance in parallel processing.
31+
32+
The overall process should usually take a couple of minutes on modern platforms.
33+
34+
35+
Tests
36+
-----
37+
38+
Following tests are run during the benchmark
39+
40+
41+
### CPU Tests
42+
- CPU32: Make some mathematical computation using 32-bit integers
43+
- CPU64: Make some mathematical computation using 64-bit integers
44+
- Float32: Make some mathematical computation using 32-bit precision floating point numbers
45+
- Float64: Make some mathematical computation using 64-bit (double) precision floating point numbers
46+
47+
48+
### RAM Tests
49+
50+
- RAM: Make copy from memory to memory zones (total of 5 GB transfer)
51+
52+
53+
### Disk Tests
54+
55+
- SmallFile: write some 1M sized temporary files
56+
57+
58+
Results
59+
-------
60+
61+
The results will show the time taken to complete all tests so, the lower result reflect a better performance.
62+
63+
As a comparison point, following results can be used as references
64+
65+
66+
### Reference 1
67+
68+
Year: 2012
69+
CPU: Intel Xeon E5 (v1) 2.2 Ghz 10M cache
70+
RAM: DDR3 1066 Mhz
71+
DISK: local SSD SATA3 disk
72+
OS: Linux 3.2.0-4-amd64 (amd64)
73+
Java: Oracle Corporation 1.7.0_65
74+
75+
CPU32: 2307 ms
76+
CPU64: 1825 ms
77+
Float32: 2754 ms
78+
Float64: 3216 ms
79+
RAM: 4655 ms
80+
SmallFile: 1077 ms
81+
82+
83+
### Reference 2
84+
85+
Year: 2014
86+
CPU: Intel Core i5 4th-gen 2.7 Ghz 2M cache
87+
RAM: DDR3 1600 Mhz
88+
DISK: local SSHD (hybrid) SATA3 disk
89+
OS: Windows 7 6.1 (amd64)
90+
Java: Oracle Corporation 1.7.0_67
91+
92+
CPU32: 1340 ms
93+
CPU64: 1990 ms
94+
Float32: 950 ms
95+
Float64: 1100 ms
96+
RAM: 2660 ms
97+
SmallFile: 2300 ms
98+
99+
100+
### Reference 3
101+
102+
Year: 2006
103+
CPU: Intel Xeon 5300 series 1.6 Ghz 8M cache
104+
RAM: DDR2 667 MHz
105+
DISK: local 7200RPM 16M-cache SATA2 disk
106+
OS: Linux 2.6.26-2-686 (i386)
107+
Java: Sun Microsystems Inc. 1.6.0_26
108+
109+
CPU32: 5616 ms
110+
CPU64: 18170 ms
111+
Float32: 5924 ms
112+
Float64: 4358 ms
113+
RAM: 11783 ms
114+
SmallFile: 4523 ms
115+
116+
117+
License
118+
-------
119+
120+
Copyright (c) 2015, W4 S.A.
121+
122+
This project is licensed under the terms of the MIT License (see LICENSE file)
123+
124+
Ce projet est licencié sous les termes de la licence MIT (voir le fichier LICENSE)

pom.xml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>eu.w4.contrib</groupId>
6+
<artifactId>misc-tool-benchmark</artifactId>
7+
<version>1.0</version>
8+
<packaging>jar</packaging>
9+
10+
<name>benchmark</name>
11+
<url>https://github.com/w4software/misc-tool-benchmark</url>
12+
13+
<properties>
14+
<maven.compiler.source>1.5</maven.compiler.source>
15+
<maven.compiler.target>1.5</maven.compiler.target>
16+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
17+
</properties>
18+
19+
<build>
20+
<plugins>
21+
<plugin>
22+
<groupId>org.apache.maven.plugins</groupId>
23+
<artifactId>maven-jar-plugin</artifactId>
24+
<version>2.6</version>
25+
<configuration>
26+
<archive>
27+
<manifest>
28+
<mainClass>eu.w4.contrib.tools.benchmark.Benchmark</mainClass>
29+
</manifest>
30+
</archive>
31+
</configuration>
32+
</plugin>
33+
<plugin>
34+
<artifactId>maven-assembly-plugin</artifactId>
35+
<version>2.4</version>
36+
<configuration>
37+
<descriptor>src/assembly/assembly.xml</descriptor>
38+
</configuration>
39+
<executions>
40+
<execution>
41+
<goals>
42+
<goal>single</goal>
43+
</goals>
44+
<phase>package</phase>
45+
</execution>
46+
</executions>
47+
</plugin>
48+
</plugins>
49+
</build>
50+
51+
<scm>
52+
<url>https://github.com/w4software/misc-tool-benchmark</url>
53+
<connection>scm:git:https://github.com/w4software/misc-tool-benchmark.git</connection>
54+
</scm>
55+
56+
<licenses>
57+
<license>
58+
<name>MIT</name>
59+
<url>https://github.com/w4software/misc-tool-benchmark/LICENSE</url>
60+
</license>
61+
</licenses>
62+
</project>

src/assembly/assembly.xml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
4+
<id>assembly</id>
5+
<formats>
6+
<format>tar.gz</format>
7+
<format>zip</format>
8+
</formats>
9+
<includeBaseDirectory>false</includeBaseDirectory>
10+
<fileSets>
11+
<fileSet>
12+
<directory>${project.basedir}</directory>
13+
<outputDirectory>/</outputDirectory>
14+
<includes>
15+
<include>README*</include>
16+
<include>LICENSE*</include>
17+
<include>NOTICE*</include>
18+
</includes>
19+
</fileSet>
20+
<fileSet>
21+
<directory>${project.build.directory}</directory>
22+
<outputDirectory>/</outputDirectory>
23+
<includes>
24+
<include>*.jar</include>
25+
</includes>
26+
</fileSet>
27+
</fileSets>
28+
</assembly>
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
package eu.w4.contrib.tools.benchmark;
2+
3+
import java.util.concurrent.CyclicBarrier;
4+
5+
import eu.w4.contrib.tools.benchmark.tests.CPU32;
6+
import eu.w4.contrib.tools.benchmark.tests.CPU64;
7+
import eu.w4.contrib.tools.benchmark.tests.FastCPU32;
8+
import eu.w4.contrib.tools.benchmark.tests.Float32;
9+
import eu.w4.contrib.tools.benchmark.tests.Float64;
10+
import eu.w4.contrib.tools.benchmark.tests.RAM;
11+
import eu.w4.contrib.tools.benchmark.tests.SmallFile;
12+
13+
public class Benchmark
14+
{
15+
16+
public long test(final Class<? extends Test> testClass, final int count)
17+
{
18+
final CyclicBarrier cyclicBarrier;
19+
if (count > 1)
20+
{
21+
cyclicBarrier = new CyclicBarrier(count);
22+
}
23+
else
24+
{
25+
cyclicBarrier = null;
26+
}
27+
final Test[] threads = new Test[count];
28+
for (int i = 0; i < count; i++)
29+
{
30+
Test test;
31+
try
32+
{
33+
test = testClass.newInstance();
34+
}
35+
catch (final InstantiationException e)
36+
{
37+
throw new RuntimeException(e);
38+
}
39+
catch (final IllegalAccessException e)
40+
{
41+
throw new RuntimeException(e);
42+
}
43+
test.start(cyclicBarrier);
44+
threads[i] = test;
45+
}
46+
long totalDuration = 0;
47+
for (int i = 0; i < count; i++)
48+
{
49+
try
50+
{
51+
threads[i].join();
52+
totalDuration += threads[i].getDuration();
53+
}
54+
catch (final InterruptedException e)
55+
{
56+
throw new RuntimeException(e);
57+
}
58+
}
59+
final long average = totalDuration / count;
60+
return average;
61+
}
62+
63+
public void testLog(final Class<? extends Test> testClass, final int count)
64+
{
65+
final long average = test(testClass, count);
66+
System.out.println(testClass.getSimpleName() + ": " + average + " ms");
67+
}
68+
69+
public static void main(final String[] args)
70+
throws Exception
71+
{
72+
final Benchmark benchmark = new Benchmark();
73+
final Runtime runtime = Runtime.getRuntime();
74+
75+
System.out.println("Benchmarking tool");
76+
System.out.println();
77+
System.out.println(String.format("CPU: %s logical processors available",
78+
runtime.availableProcessors()));
79+
System.out.println(String.format("OS: %s %s (%s)",
80+
System.getProperty("os.name"),
81+
System.getProperty("os.version"),
82+
System.getProperty("os.arch")));
83+
System.out.println(String.format("Java: %s %s",
84+
System.getProperty("java.vendor"),
85+
System.getProperty("java.version")));
86+
System.out.println();
87+
88+
int n;
89+
if (args.length >= 1)
90+
{
91+
n = Integer.parseInt(args[0]);
92+
}
93+
else
94+
{
95+
n = runtime.availableProcessors();
96+
final long durationAll = benchmark.test(FastCPU32.class, n);
97+
final long durationHalf = benchmark.test(FastCPU32.class, n/2);
98+
final long ratio = 100*(durationAll - durationHalf) / durationHalf;
99+
if (ratio >= 10)
100+
{
101+
n /= 2;
102+
System.out.println("Hyperthreading detected.");
103+
}
104+
else
105+
{
106+
System.out.println("Hyperthreading not detected.");
107+
}
108+
System.out.println("If this is not correct, you can provide manually the number of threads to use on command line");
109+
}
110+
111+
System.out.println();
112+
System.out.println("Test using " + n + " threads");
113+
benchmark.testLog(CPU32.class, n);
114+
benchmark.testLog(CPU64.class, n);
115+
benchmark.testLog(Float32.class, n);
116+
benchmark.testLog(Float64.class, n);
117+
benchmark.testLog(RAM.class, 1);
118+
benchmark.testLog(SmallFile.class, 1);
119+
System.out.println("");
120+
System.out.println("The results are expressed in ms (the lower, the better)");
121+
}
122+
}

0 commit comments

Comments
 (0)