---
title: Google謹製のJavaベンチマーク用フレームワークCaliper
tags: []
categories: ["Programming", "Java", "com", "google", "caliper"]
date: 2013-07-15T08:56:12Z
updated: 2013-07-15T08:56:12Z
---

Javaでベンチマークを書くためのフレームワークがGoogleから出ていた。

https://code.google.com/p/caliper/

こんな風に書けるみたい。

    import com.google.caliper.Benchmark;
    import com.google.caliper.Param;
    
    import java.security.MessageDigest;
    
    /**
     * Times creating new MessageDigest instances.
     */
    public class MessageDigestCreationBenchmark {
      // By default, just the "interesting ones". Also consider Adler32 and CRC32,
      // but these are not guaranteed to be supported in all runtime environments.
      @Param({"MD5", "SHA-1", "SHA-256", "SHA-512"})
      String algorithm;
    
      @Benchmark void time(int reps) throws Exception {
        // Change this to use a dummy if the results look suspicious.
        for (int i = 0; i < reps; i++) {
          MessageDigest.getInstance(algorithm);
        }
      }
    }


後で試してここに追記する。
