forked from btorpey/clocks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ClockTest.sh
executable file
·52 lines (46 loc) · 1.73 KB
/
ClockTest.sh
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
#!/bin/bash
#
# Copyright 2014 by Bill Torpey. All Rights Reserved.
# This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 United States License.
# http://creativecommons.org/licenses/by-nc-nd/3.0/us/deed.en
#
# Either set JAVA_HOME before running, or change to point to jdk installation
export JAVA_HOME=/Library/java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home
if [ "$JAVA_HOME" == "" ] ; then
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.45.x86_64
fi
export PATH=$JAVA_HOME/bin:$PATH
if [[ ${OSTYPE} == *linux* ]]; then
LIBRT="-lrt"
TASKSET="taskset -c 1"
JAVAINC=linux
SOEXT=so
# does this machine have rdtscp instruction?
if [[ $(grep rdtscp /proc/cpuinfo | wc -l) -gt 0 ]] ; then
RDTSCP=" -DRDTSCP=1 "
fi
elif [[ ${OSTYPE} == *darwin* ]]; then
# assume RDTSCP -- not sure what else to do
RDTSCP=" -DRDTSCP=1 "
JAVAINC=darwin
SOEXT=jnilib
fi
## show available clocks
echo;echo "clocks.c"
gcc -o clocks clocks.c ${LIBRT} && ./clocks
# benchmark clocks
# cpp side
echo;echo "ClockBench.cpp"
g++ -O3 -ggdb ${LIBRT} ${RDTSCP} -o ClockBench ClockBench.cpp && ${TASKSET} ./ClockBench $*
# java side
rm -f SysTime.h
rm -f SysTime.class
rm -f ClockBench.class
rm -f libsystime.${SOEXT}
javac -classpath . SysTime.java
javah -classpath . SysTime
javac -classpath . ClockBench.java
#gcc -O3 -o libsystime.so -shared -Wl,-soname,systime.so -I${JAVA_HOME}/include -I${JAVA_HOME}/include/${JAVAINC} -lc -fPIC ${LIBRT} SysTime.c
gcc -O3 -o libsystime.${SOEXT} -shared -I${JAVA_HOME}/include -I${JAVA_HOME}/include/${JAVAINC} -lc -fPIC ${LIBRT} SysTime.c
echo;echo "ClockBench.java"
(export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH;java -Djava.library.path=. ${RDTSCP} -server -classpath . ClockBench $*)