Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.google.caliper.timsort;
- import com.google.caliper.timsort.SortingAlgorithms;
- import java.util.Random;
- import com.google.caliper.AfterExperiment;
- import com.google.caliper.BeforeExperiment;
- import com.google.caliper.Benchmark;
- public final class TimsortBenchmark {
- Random rand = new Random(0607);
- Integer[] tab = new Integer[64];
- Integer[] temp;
- @BeforeExperiment void setUp() {
- tab[0] = 1;
- for(int i = 1; i < tab.length; i++){
- tab[i] = rand.nextInt();
- //tab[i] = tab[i - 1] - 20 + (rand.nextInt(100 - 1 + 1) + 1);
- }
- temp = new Integer[2 * tab.length];
- }
- @AfterExperiment void tearDown(){
- tab = null;
- temp = null;
- }
- @Benchmark void binarySort(int reps) {
- for (int i = 0; i < reps; i++) {
- SortingAlgorithms.binarySort(tab);
- }
- }
- @Benchmark void insertSort(int reps) {
- for (int i = 0; i < reps; i++) {
- SortingAlgorithms.insertSort(tab, temp);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement