Skip to content

Commit 80ba9af

Browse files
committed
First version of the code for jni-construction-benchmark
1 parent 53265ab commit 80ba9af

15 files changed

+762
-9
lines changed

Diff for: .gitignore

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
*.class
1+
target/
22

3-
# Mobile Tools for Java (J2ME)
4-
.mtj.tmp/
5-
6-
# Package Files #
7-
*.jar
8-
*.war
9-
*.ear
3+
.idea/
4+
*.iml
105

116
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
127
hs_err_pid*

Diff for: LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2016, Adam Retter
1+
Copyright (c) 2016, Evolved Binary Ltd
22
All rights reserved.
33

44
Redistribution and use in source and binary forms, with or without

Diff for: pom.xml

+141
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.evolvedbinary.jni</groupId>
8+
<artifactId>jni-construction-benchmark</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
<packaging>nar</packaging>
11+
12+
<scm>
13+
<connection>scm:git:https://github.com/adamretter/jni-construction-benchmark.git</connection>
14+
<developerConnection>scm:git:https://github.com/adamretter/jni-construction-benchmark.git</developerConnection>
15+
<url>scm:git:https://github.com/adamretter/jni-construction-benchmark.git</url>
16+
</scm>
17+
18+
<description>A small benchmark to compare costs of JNI object construction</description>
19+
<url>https://github.com/adamretter/jni-construction-benchmark</url>
20+
<inceptionYear>2016</inceptionYear>
21+
22+
<organization>
23+
<name>Evolved Binary Ltd</name>
24+
</organization>
25+
26+
<developers>
27+
<developer>
28+
<name>Adam Retter</name>
29+
<organization>Evolved Binary Ltd</organization>
30+
<timezone>GMT</timezone>
31+
</developer>
32+
</developers>
33+
34+
<licenses>
35+
<license>
36+
<name>The BSD 3-Clause License</name>
37+
<url>http://www.opensource.org/licenses/BSD-3-Clause</url>
38+
<distribution>repo</distribution>
39+
</license>
40+
</licenses>
41+
42+
<properties>
43+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
44+
</properties>
45+
46+
<build>
47+
<plugins>
48+
<plugin>
49+
<groupId>com.github.maven-nar</groupId>
50+
<artifactId>nar-maven-plugin</artifactId>
51+
<version>3.2.3</version>
52+
<extensions>true</extensions>
53+
<configuration>
54+
<libraries>
55+
<library>
56+
<type>jni</type>
57+
<narSystemPackage>com.evolvedbinary.jni.consbench</narSystemPackage>
58+
</library>
59+
</libraries>
60+
<cpp>
61+
<options>
62+
<option>-std=c++11</option>
63+
</options>
64+
</cpp>
65+
</configuration>
66+
</plugin>
67+
68+
<plugin>
69+
<groupId>com.mycila</groupId>
70+
<artifactId>license-maven-plugin</artifactId>
71+
<version>2.11</version>
72+
<inherited>true</inherited>
73+
<configuration>
74+
<header>com/mycila/maven/plugin/license/templates/BSD-3.txt</header>
75+
<failIfMissing>true</failIfMissing>
76+
<aggregate>true</aggregate>
77+
<strictCheck>true</strictCheck>
78+
<excludes>
79+
<exclude>LICENSE</exclude>
80+
<exclude>**/pom.xml</exclude>
81+
<exclude>src/main/assembly/*</exclude>
82+
</excludes>
83+
<properties>
84+
<owner>${project.organization.name}</owner>
85+
</properties>
86+
<encoding>${project.build.sourceEncoding}</encoding>
87+
</configuration>
88+
</plugin>
89+
90+
<plugin>
91+
<groupId>org.codehaus.mojo</groupId>
92+
<artifactId>appassembler-maven-plugin</artifactId>
93+
<version>1.10</version>
94+
<executions>
95+
<execution>
96+
<phase>package</phase>
97+
<goals>
98+
<goal>assemble</goal>
99+
</goals>
100+
</execution>
101+
</executions>
102+
<configuration>
103+
<licenseHeaderFile>LICENSE</licenseHeaderFile>
104+
<includeConfigurationDirectoryInClasspath>false</includeConfigurationDirectoryInClasspath>
105+
<repositoryLayout>flat</repositoryLayout>
106+
<repositoryName>lib</repositoryName>
107+
<programs>
108+
<program>
109+
<id>benchmark</id>
110+
<mainClass>com.evolvedbinary.jni.consbench.Benchmark</mainClass>
111+
<jvmSettings>
112+
<extraArguments>
113+
<extraArgument>-Djava.library.path=$REPO</extraArgument>
114+
</extraArguments>
115+
</jvmSettings>
116+
</program>
117+
</programs>
118+
</configuration>
119+
</plugin>
120+
121+
<plugin>
122+
<artifactId>maven-assembly-plugin</artifactId>
123+
<executions>
124+
<execution>
125+
<phase>package</phase>
126+
<goals>
127+
<goal>single</goal>
128+
</goals>
129+
</execution>
130+
</executions>
131+
<configuration>
132+
<descriptors>
133+
<descriptor>src/main/assembly/appassembler-output.xml</descriptor>
134+
</descriptors>
135+
</configuration>
136+
</plugin>
137+
138+
</plugins>
139+
</build>
140+
141+
</project>

Diff for: src/main/assembly/appassembler-output.xml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
4+
<id>application</id>
5+
<formats>
6+
<format>dir</format>
7+
<format>zip</format>
8+
</formats>
9+
10+
<includeBaseDirectory>true</includeBaseDirectory>
11+
12+
<fileSets>
13+
14+
<!-- add the unix shell file in th bin folder, and set the execute bit -->
15+
<fileSet>
16+
<directory>${project.build.directory}/appassembler</directory>
17+
<includes>
18+
<include>bin/${project.artifactId}</include>
19+
</includes>
20+
<fileMode>755</fileMode>
21+
<outputDirectory>/</outputDirectory>
22+
</fileSet>
23+
24+
<!-- add any other scripts from the bin folder, e.g. windows scripts -->
25+
<fileSet>
26+
<directory>${project.build.directory}/appassembler/bin</directory>
27+
<excludes>
28+
<exclude>bin/${project.artifactId}</exclude>
29+
</excludes>
30+
<outputDirectory>/bin</outputDirectory>
31+
</fileSet>
32+
33+
<!-- add all other folders, but not the bin folder as we have done this above -->
34+
<fileSet>
35+
<directory>${project.build.directory}/appassembler</directory>
36+
<excludes>
37+
<exclude>bin</exclude>
38+
</excludes>
39+
<outputDirectory>/</outputDirectory>
40+
</fileSet>
41+
42+
<fileSet>
43+
<directory>${project.build.directory}/nar/${project.artifactId}-${project.version}-${nar.aol}-jni/lib/${nar.aol}/jni</directory>
44+
<includes>
45+
<include>*.jnilib</include>
46+
<include>*.dylib</include>
47+
<include>*.so</include>
48+
<include>*.dll</include>
49+
</includes>
50+
<outputDirectory>/lib</outputDirectory>
51+
</fileSet>
52+
53+
</fileSets>
54+
55+
<files>
56+
<file>
57+
<source>LICENSE</source>
58+
<outputDirectory>/</outputDirectory>
59+
</file>
60+
</files>
61+
62+
</assembly>

Diff for: src/main/c++/Foo.cpp

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* Copyright © 2016, Evolved Binary Ltd
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
* * Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* * Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
* * Neither the name of the <organization> nor the
13+
* names of its contributors may be used to endorse or promote products
14+
* derived from this software without specific prior written permission.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
20+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
*/
27+
#include "Foo.h"
28+
29+
namespace consbench {
30+
Foo::Foo() {
31+
}
32+
33+
Foo::~Foo() {
34+
}
35+
}

Diff for: src/main/c++/Foo.h

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* Copyright © 2016, Evolved Binary Ltd
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
* * Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* * Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
* * Neither the name of the <organization> nor the
13+
* names of its contributors may be used to endorse or promote products
14+
* derived from this software without specific prior written permission.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
20+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
*/
27+
#ifndef FOO_H_
28+
#define FOO_H_
29+
30+
namespace consbench{
31+
class Foo {
32+
public:
33+
Foo();
34+
~Foo();
35+
};
36+
} //end namspace consbench
37+
38+
#endif // FOO

Diff for: src/main/c++/FooByCall.cpp

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* Copyright © 2016, Evolved Binary Ltd
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
* * Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* * Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
* * Neither the name of the <organization> nor the
13+
* names of its contributors may be used to endorse or promote products
14+
* derived from this software without specific prior written permission.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
20+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
*/
27+
#include <jni.h>
28+
#include "com_evolvedbinary_jni_consbench_FooByCall.h"
29+
#include "Foo.h"
30+
31+
/*
32+
* Class: com_evolvedbinary_jni_consbench_FooByCall
33+
* Method: newFoo
34+
* Signature: ()J
35+
*/
36+
jlong Java_com_evolvedbinary_jni_consbench_FooByCall_newFoo(JNIEnv* env, jobject jobj) {
37+
consbench::Foo* foo = new consbench::Foo();
38+
return reinterpret_cast<jlong>(foo);
39+
}
40+
41+
/*
42+
* Class: com_evolvedbinary_jni_consbench_FooByCall
43+
* Method: disposeInternal
44+
* Signature: (J)V
45+
*/
46+
void Java_com_evolvedbinary_jni_consbench_FooByCall_disposeInternal(JNIEnv* env, jobject jobj, jlong handle) {
47+
delete reinterpret_cast<consbench::Foo*>(handle);
48+
}

0 commit comments

Comments
 (0)