sebastiangraf / perfidix Goto Github PK
View Code? Open in Web Editor NEWPerfidix - No discussions, Just facts.
Home Page: http://perfidix.org
License: BSD 3-Clause "New" or "Revised" License
Perfidix - No discussions, Just facts.
Home Page: http://perfidix.org
License: BSD 3-Clause "New" or "Revised" License
Using an @bench annotation, but leaving out the number of runs causes the number of runs to be taken from the Benchmark configuration (default: 10) instead of the runs definition of the @BenchClass annotation on the class (if available).
While installing plugin in eclipse neon, getting error http://disy.github.com/perclipse/ path not found.
Hi,
This is the the tutorial code (slightly modified because the original didn't work)
When I run this perfidix bench then in the perfidix bench the tests run without errors but in the console I get
|= Benchmark ===============================================|
| - | unit | sum | min | max | avg | stddev | conf95 | runs |
|============= Summary for the whole benchmark =============|
|======================= Exceptions ========================|
| Related exception: IllegalAccessException |
| Related place: method check |
| Related method: beforeClass |
| Related annotation: BeforeBenchClass |
|-----------------------------------------------------------|
|===========================================================|
package org.example;
import java.util.Random;
import java.util.Stack;
import org.junit.BeforeClass;
import org.junit.Test;
import org.perfidix.annotation.*;
@BenchClass(runs = 100)
public class FastIntStackTest {
private static int[] data = new int[15];
@BeforeBenchClass
@BeforeClass
public static void beforeClass() {
for (int i = 0; i < data.length; i++) {
data[i] = new Random().nextInt();
}
}
@Test
public void myStackTest() {
final FastIntStack myStack = new FastIntStack();
for (int i = 0; i < data.length; i++) {
myStack.push(data[i]);
}
for (int i = data.length - 1; i > 0; i--) {
assert(data[i] == myStack.pop());
}
}
@Test
public void normalStackTest() {
final Stack<Integer> normalStack = new Stack<Integer>();
for (int i = 0; i < data.length; i++) {
normalStack.push(data[i]);
}
for (int i = data.length - 1; i > 0; i--) {
assert(data[i] == normalStack.pop());
}
}
final class FastIntStack {
private int[] stack;
private int size;
FastIntStack() {
stack = new int[32];
size = 0;
}
final void push(final int element) {
if (stack.length == size) {
int[] biggerStack = new int[stack.length << 1];
System.arraycopy(stack, 0, biggerStack, 0, stack.length);
stack = biggerStack;
}
stack[size++] = element;
}
final int peek() {
return stack[size - 1];
}
final int get(final int position) {
return stack[position];
}
final int pop() {
return stack[--size];
}
final void clear() {
size = 0;
}
final int size() {
return size;
}
}
}
used:
windows 7 32 bit sp1
perclipse 2.1.0
perfidix 3.6.6
eclipse 3.7.2
jdk 1.6.0_u33
Eclipse .log shows only this
!ENTRY org.perfidix.perclipse 1 1 2012-08-05 18:09:05.641
!MESSAGE Benching scala-benchmarking-template
!ENTRY org.perfidix.perclipse 1 1 2012-08-05 18:09:07.638
!MESSAGE Bench process finished
-- Dave
Hi Sebastian,
I like to use perfidix/perclipse with Scala. Since 2.10.0-M6 Scala supports the @static annotation.
I translated the hacked tutorial to Scala
package org.example
import org.junit.Assert
import java.util.Random
import java.util.Stack
import org.junit.BeforeClass
import org.junit.Test
import org.perfidix.annotation._
import scala.annotation.static
object FastIntStack2Test {
@static
private[FastIntStack2Test] var data = new Array[Int](15)
@BeforeBenchClass
@BeforeClass
@static
def beforeClass() {
for (i <- 0 until data.length) {
data(i) = new Random().nextInt()
}
}
}
@BenchClass(runs = 100)
class FastIntStack2Test {
val static = FastIntStack2Test
@Test
def myStackTest() {
var myStack = new FastIntStack()
for (i <- 0 until static.data.length) {
myStack.push(static.data(i))
}
for (i <- (static.data.length - 1 to 0 by -1)) {
assert(static.data(i) == myStack.pop())
}
}
@Test
def normalStackTest() {
var normalStack = new Stack[Integer]()
for (i <- 0 until static.data.length) {
normalStack.push(static.data(i))
}
for (i <- (static.data.length - 1 to 0 by -1)) {
assert(static.data(i) == normalStack.pop())
}
}
final class FastIntStack {
private var stack: Array[Int] = new Array[Int](32)
private var size: Int = _
final def push(element: Int) {
if (stack.length == size) {
var biggerStack = new Array[Int](stack.length << 1)
System.arraycopy(stack, 0, biggerStack, 0, stack.length)
stack = biggerStack
}
stack(size) = element
size += 1
}
final def peek() : Int = {
stack(size - 1)
}
final def get(position: Int) : Int = {
stack(position)
}
final def pop(): Int = {
size -= 1
stack(size)
}
final def clear() {
size = 0
}
}
}
but in eclipse nothing happens. In .log I have this error
!ENTRY org.perfidix.perclipse 4 4 2012-08-06 12:21:34.103
!MESSAGE Error
!STACK 0
java.lang.StringIndexOutOfBoundsException: String index out of range: -16
at java.lang.String.substring(String.java:1937)
at org.perfidix.perclipse.util.BenchFinder$Annotation.annotates(BenchFinder.java:315)
at org.perfidix.perclipse.util.BenchFinder$Annotation.annotatesAtLeastOneMethod(BenchFinder.java:344)
at org.perfidix.perclipse.util.BenchFinder$Annotation.access$0(BenchFinder.java:339)
at org.perfidix.perclipse.util.BenchFinder.isBench(BenchFinder.java:221)
at org.perfidix.perclipse.util.BenchFinder.findBenchsInType(BenchFinder.java:204)
at org.perfidix.perclipse.util.BenchFinder.findBenchsInCompilationUnit(BenchFinder.java:188)
at org.perfidix.perclipse.util.BenchFinder.findBenchsInPackageFragment(BenchFinder.java:170)
at org.perfidix.perclipse.util.BenchFinder.findBenchsInPackageFragmentRoot(BenchFinder.java:151)
at org.perfidix.perclipse.util.BenchFinder.findBenchsInProject(BenchFinder.java:133)
at org.perfidix.perclipse.util.BenchFinder.findBenchsInContainer(BenchFinder.java:88)
at org.perfidix.perclipse.util.BenchSearchEngine.findBenchs(BenchSearchEngine.java:136)
at org.perfidix.perclipse.launcher.PerfidixLaunchConfiguration.findBenchTypes(PerfidixLaunchConfiguration.java:147)
at org.perfidix.perclipse.launcher.PerfidixLaunchConfiguration.launch(PerfidixLaunchConfiguration.java:91)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:854)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:703)
at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:937)
at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1141)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
When I look into the source op perclipse at org.perfidix.perclipse.util.BenchFinder$Annotation.annotates(BenchFinder.java:315)
private boolean annotates(final IMember member)
throws JavaModelException {
final ISourceRange sourceRange = member.getSourceRange();
final ISourceRange nameRange = member.getNameRange();
final int charsToSearch =
nameRange.getOffset() - sourceRange.getOffset();
final String source =
member.getSource().substring(0, charsToSearch);
return foundIn(source);
}
So it has something to do about how perclipse derives names.
A scala sourcefilename doesn't have to correspond to the class name.
Is it possible to make it Scala compatible?
-- Dave
Just recognized that any bench annotated with 'afterLastRun' acts like 'beforeFirstRun'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.