Last active
January 3, 2016 20:58
-
-
Save whiter4bbit/8518142 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package bench; | |
import com.clearspring.analytics.stream.quantile.QDigest; | |
public class QDigestBenchmark { | |
public static void main(String[] args) throws Exception { | |
QDigest q = new QDigest(1000); | |
for (int k : Utils.readNumbers(args[0])) { | |
q.offer(k); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% time bin/start.sh bench.TDigestBenchmark input.txt | |
bin/start.sh bench.TDigestBenchmark input.txt 4,71s user 0,19s system 150% cpu 3,263 total | |
% time bin/start.sh bench.TDigestBenchmark input.txt | |
bin/start.sh bench.TDigestBenchmark input.txt 4,37s user 0,16s system 153% cpu 2,946 total | |
% time bin/start.sh bench.TDigestBenchmark input.txt | |
bin/start.sh bench.TDigestBenchmark input.txt 4,24s user 0,15s system 149% cpu 2,930 total | |
% time bin/start.sh bench.TDigestBenchmark input.txt | |
bin/start.sh bench.TDigestBenchmark input.txt 4,04s user 0,14s system 155% cpu 2,694 total | |
% time bin/start.sh bench.TDigestBenchmark input.txt | |
bin/start.sh bench.TDigestBenchmark input.txt 4,49s user 0,15s system 158% cpu 2,921 total | |
% time bin/start.sh bench.TDigestBenchmark input.txt | |
bin/start.sh bench.TDigestBenchmark input.txt 4,32s user 0,16s system 161% cpu 2,774 total | |
% time bin/start.sh bench.QDigestBenchmark input.txt | |
bin/start.sh bench.QDigestBenchmark input.txt 1,21s user 0,04s system 148% cpu 0,846 total | |
% time bin/start.sh bench.QDigestBenchmark input.txt | |
bin/start.sh bench.QDigestBenchmark input.txt 1,15s user 0,06s system 177% cpu 0,683 total | |
% time bin/start.sh bench.QDigestBenchmark input.txt | |
bin/start.sh bench.QDigestBenchmark input.txt 1,14s user 0,06s system 186% cpu 0,640 total | |
% time bin/start.sh bench.QDigestBenchmark input.txt | |
bin/start.sh bench.QDigestBenchmark input.txt 1,14s user 0,05s system 176% cpu 0,675 total | |
% time bin/start.sh bench.QDigestBenchmark input.txt | |
bin/start.sh bench.QDigestBenchmark input.txt 1,14s user 0,06s system 194% cpu 0,615 total |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package bench; | |
import com.tdunning.math.stats.TDigest; | |
import java.util.Random; | |
public class TDigestBenchmark { | |
public static void main(String[] args) throws Exception { | |
TDigest td = new TDigest(0.001); | |
Random rnd = new Random(); | |
for (int k : Utils.readNumbers(args[0])) { | |
//if (k != 444) td.add(k); else td.add(rnd.nextInt()); | |
td.add(k); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package bench; | |
import java.io.BufferedReader; | |
import java.io.FileReader; | |
import java.io.IOException; | |
import java.util.ArrayList; | |
import java.util.List; | |
public class Utils { | |
public static List<Integer> readNumbers(String file) throws IOException { | |
List<Integer> numbers = new ArrayList<>(); | |
try (BufferedReader reader = new BufferedReader(new FileReader(file))) { | |
while (true) { | |
String line = reader.readLine(); | |
if (line == null) break; | |
numbers.add(Integer.parseInt(line)); | |
} | |
} | |
return numbers; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment