Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
sam committed Aug 13, 2012
0 parents commit 8144711
Show file tree
Hide file tree
Showing 5 changed files with 176 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target
36 changes: 36 additions & 0 deletions README.textile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
h1. Hash vs Hazelcast vs Infinispan

h2. Overview

This is just a simple benchmark to compare Hazelcast and Infinispan performance (with defaults), and includes a regular Hash object as a baseline.

h2. Usage

From the root of the project run:

bc. mvn clean install

Then you can just start it up:

bc. java -jar target/map-benchmarks-1.0.0.jar

h2. Results:

On a Core 2 Duo laptop running at 2.66GHz these are my results:

bc.. Rehearsal --------------------------------------------------
Hash:set 0.280000 0.010000 0.290000 ( 0.223000)
Hazelcast:set 34.890000 2.200000 37.090000 ( 36.979000)
Infinispan:set 0.900000 0.030000 0.930000 ( 0.628000)
Hash:get 0.280000 0.010000 0.290000 ( 0.176000)
Hazelcast:get 31.400000 1.280000 32.680000 ( 32.997000)
Infinispan:get 0.230000 0.010000 0.240000 ( 0.147000)
---------------------------------------- total: 71.520000sec

user system total real
Hash:set 0.010000 0.000000 0.010000 ( 0.011000)
Hazelcast:set 60.140000 2.550000 62.690000 ( 63.818000)
Infinispan:set 0.110000 0.010000 0.120000 ( 0.098000)
Hash:get 0.010000 0.000000 0.010000 ( 0.007000)
Hazelcast:get 30.130000 1.180000 31.310000 ( 31.637000)
Infinispan:get 0.020000 0.000000 0.020000 ( 0.018000)
29 changes: 29 additions & 0 deletions assembly.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<assembly>
<id>artifact</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${basedir}/src/main/ruby</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
<!-- <fileSet> We'd use this if we had gem dependencies...
<directory>${basedir}/lib/jruby/1.9</directory>
<outputDirectory>/</outputDirectory>
</fileSet> -->
</fileSets>
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<outputFileNameMapping></outputFileNameMapping>
<unpack>true</unpack>
<unpackOptions>
<excludes>
<exclude>META-INF/MANIFEST.MF</exclude>
</excludes>
</unpackOptions>
</dependencySet>
</dependencySets>
</assembly>
57 changes: 57 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.sam</groupId>
<artifactId>map-benchmarks</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<name>map-benchmarks</name>
<dependencies>
<dependency>
<groupId>org.jruby</groupId>
<artifactId>jruby-complete</artifactId>
<version>1.7.0.preview2</version>
</dependency>
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-core</artifactId>
<version>5.1.5.FINAL</version>
</dependency>
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast</artifactId>
<version>2.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-3</version>
<executions>
<execution>
<id>assemble</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
<configuration>
<archive>
<manifest>
<mainClass>org.jruby.JarBootstrapMain</mainClass>
</manifest>
</archive>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
53 changes: 53 additions & 0 deletions src/main/ruby/jar-bootstrap.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
require "java"

hash_map = {}

java_import com.hazelcast.core.Hazelcast
at_exit { Hazelcast.shutdown_all }
hazel_map = Hazelcast.get_map "benchmark"

java_import org.infinispan.Cache
java_import org.infinispan.manager.DefaultCacheManager
infinispan_map = DefaultCacheManager.new.get_cache

require "benchmark"

COUNT = 10_000

def iterate_set(map)
COUNT.times do |i|
map[i.to_s] = i
end
end

def iterate_get(map)
COUNT.times do |i|
map[i.to_s].to_s
end
end

Benchmark::bmbm do |x|
x.report("Hash:set") do
iterate_set hash_map
end

x.report("Hazelcast:set") do
iterate_set hazel_map
end

x.report("Infinispan:set") do
iterate_set infinispan_map
end

x.report("Hash:get") do
iterate_get hash_map
end

x.report("Hazelcast:get") do
iterate_get hazel_map
end

x.report("Infinispan:get") do
iterate_get infinispan_map
end
end

0 comments on commit 8144711

Please sign in to comment.