dislproj: done ex1
This commit is contained in:
parent
031b07d70e
commit
3eefaaba0a
2 changed files with 48 additions and 0 deletions
25
DiSLProject2022/run-instr.sh
Executable file
25
DiSLProject2022/run-instr.sh
Executable file
|
@ -0,0 +1,25 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ "$#" -ne 1 ]; then
|
||||||
|
echo "Usage: $0 <Number of exercise>"
|
||||||
|
exit;
|
||||||
|
fi
|
||||||
|
|
||||||
|
exnum="$1"
|
||||||
|
|
||||||
|
dir="$(dirname -- "${BASH_SOURCE[0]}")"
|
||||||
|
cd "$dir"
|
||||||
|
|
||||||
|
ant clean
|
||||||
|
ant "-Ddislclass=ex$exnum.Instrumentation"
|
||||||
|
|
||||||
|
printf "\e[32mRunning without instrumentation...\e[0m\n"
|
||||||
|
time ./run.sh "ex$exnum.Main"
|
||||||
|
./startDiSLServer.sh
|
||||||
|
sleep 1
|
||||||
|
printf "\e[32mRunning WITH instrumentation...\e[0m\n"
|
||||||
|
time ./runInstrumented.sh "ex$exnum.Main"
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,27 @@
|
||||||
package ex1;
|
package ex1;
|
||||||
|
|
||||||
|
import ch.usi.dag.disl.annotation.After;
|
||||||
|
import ch.usi.dag.disl.annotation.Before;
|
||||||
|
import ch.usi.dag.disl.annotation.SyntheticLocal;
|
||||||
|
import ch.usi.dag.disl.marker.BodyMarker;
|
||||||
|
import ch.usi.dag.disl.staticcontext.MethodStaticContext;
|
||||||
|
|
||||||
public class Instrumentation {
|
public class Instrumentation {
|
||||||
|
|
||||||
|
@SyntheticLocal
|
||||||
|
static long entryTimestamp;
|
||||||
|
|
||||||
|
@Before(marker = BodyMarker.class, scope = "ex1.MainThread.factorial")
|
||||||
|
static void beforeMethod() {
|
||||||
|
entryTimestamp = System.nanoTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
@After(marker = BodyMarker.class, scope = "ex1.MainThread.factorial")
|
||||||
|
static void afterMethod(final MethodStaticContext ctx) {
|
||||||
|
final long endTimestamp = System.nanoTime();
|
||||||
|
System.out.printf("%s - Execution time for %s: %d ns%n",
|
||||||
|
Thread.currentThread().getName(),
|
||||||
|
ctx.getUniqueInternalName(),
|
||||||
|
endTimestamp - entryTimestamp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue