Skip to content

Instantly share code, notes, and snippets.

View mdakin's full-sized avatar

mdakin mdakin

  • Google
  • Zurich, Switzerland
View GitHub Profile
@mdakin
mdakin / gist:2556620
Created April 30, 2012 08:37
Some Set microbenchmarks
private static final int LIST_SIZE = 500000;
private static final int ITER = 3;
private static void testAdd(Set<String> set, List<String> data) {
final long start = System.currentTimeMillis();
for (int i = 0; i < data.size(); ++i) {
set.add(data.get(i));
}
final long elapsed = System.currentTimeMillis() - start;
System.out.println("testAdd: " + elapsed);
@mdakin
mdakin / gist:2572868
Created May 2, 2012 01:24
Perforance test of basic set operations in dart
void runTests(Set<String> se, List<String> data) {
Stopwatch w = new Stopwatch();
w.start();
for (String s in data) {
se.add(s);
}
print("Add: ${w.elapsedInMs()} ms.");
num i = 0;
w.reset();
for (String s in data) {
@mdakin
mdakin / gist:2572903
Created May 2, 2012 01:32
Java hashset perf test
private static void runTests(HashSet<String> se, List<String> data) {
Stopwatch stopWatch = new Stopwatch().start();
for (String s : data) {
se.add(s);
}
System.out.println("Add:" + stopWatch.elapsedMillis() + " ms.");
int i = 0;
stopWatch.reset().start();
for (String s : data) {
if (se.contains(s)) {
@mdakin
mdakin / gist:2572904
Created May 2, 2012 01:32
Java hashset perf test
private static void runTests(HashSet<String> se, List<String> data) {
Stopwatch stopWatch = new Stopwatch().start();
for (String s : data) {
se.add(s);
}
System.out.println("Add:" + stopWatch.elapsedMillis() + " ms.");
int i = 0;
stopWatch.reset().start();
for (String s : data) {
if (se.contains(s)) {
@mdakin
mdakin / gist:4945556
Created February 13, 2013 15:50
Simple lexer for parsing text (only ascii)
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
lexer grammar TestLexer;
@header {
package lexer;
}
@mdakin
mdakin / gist:4945563
Created February 13, 2013 15:50
Simple lexer for parsing text, including Turkish chars
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
lexer grammar TestLexer;
@header {
package lexer;
}
@mdakin
mdakin / gist:4945567
Created February 13, 2013 15:51
Test application for simple lexer
package lexer;
import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.Token;
public class Test {
private static String testStr =
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy" +
" nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim " +
@mdakin
mdakin / gist:4945570
Created February 13, 2013 15:51
Test app
package lexer;
import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.Token;
public class Test {
private static String testStr =
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy" +
" nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim " +
@mdakin
mdakin / gist:5130420
Created March 10, 2013 21:07
dart base64 perf test.
import 'dart:math';
var random = new Random(0xCAFEBABE);
/// The base64 encoding table
final List<int>characters = const [
// A-Z [65-90]
65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
// a-z [97-122]
97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
@mdakin
mdakin / gist:9108419
Created February 20, 2014 07:09
Typed array performance 1
import "dart:typed_data";
import "dart:math";
void main() {
int rs = 1000000;
int iter = 50;
Float64List rnd = new Float64List(rs);
Random r = new Random(1);
for (int i = 0; i < rs; i++) {
rnd[i] = r.nextDouble() * PI;