How to use a caliper for benchmarking?

I'm trying to figure out how to use Caliper to test tests in Eclipse, and I won’t go anywhere. I tried after the 26-minute tutorial found here: https://code.google.com/p/caliper/ , but I'm quickly lost. I uploaded the Caliper container file, but I'm not sure which folder it should be in. I also downloaded Maven for the Eclipse plugin, but I'm not even sure if this is necessary. Can I install "Caliber" from "Install New Software .." in the Help menu in Eclipse? I just want to make very simple speed tests for some of the algorithms that I created for the Data Structures and Algorithms class that I accept.

+4
source share
2 answers

This answer is now outdated. Caliper has been working on Windows for over a year, at least: https://code.google.com/p/caliper/issues/detail?id=167


Caliper does not work on Windows. See this case. You need to use version 0.5-rc1, which has other problems, but is still pretty good and lacks a lot of features, but it works on Windows.

  • If you know how to use Maven, add this pom snippet to your pom.xml.

    <dependency>
        <groupId>com.google.caliper</groupId>
        <artifactId>caliper</artifactId>
        <version>0.5-rc1</version>
    </dependency>
    
  • , Maven ( ):
    • 0.5-rc1
    • , , Build Path -> Configure Build Path
    • Add External Jar

, . , .

+7

Caliper , caliper-1.0-beta2. , - .

caliper-1.0-beta2 pom.xml jar. :

import com.google.caliper.Benchmark;
import com.google.caliper.runner.CaliperMain;

public class DemoBenchmark {
  public static void main(String[] args) {
    CaliperMain.main(DemoBenchmark.class, args);
  }

  @Benchmark
  void timeStringBuilder(int reps) {
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < reps; i++) {
      sb.setLength(0);
      sb.append("hello world");
    }
  }
}

, Caliper .

+2

Source: https://habr.com/ru/post/1523601/


All Articles