All Downloads are FREE. Search and download functionalities are using the official Maven repository.

convex.benchmarks.HashBenchmark Maven / Gradle / Ivy

There is a newer version: 0.7.15
Show newest version
package  convex.benchmarks;

import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.options.Options;

import convex.core.crypto.Hashing;
import convex.core.data.AArrayBlob;
import convex.core.data.Blob;
import convex.core.data.Format;
import convex.core.data.prim.CVMLong;

/**
 * Benchmarks for hashing performance.
 * 
 * Included to test hashing algorithm performance, since this might be a
 * bottleneck in some scenarios.
 */
public class HashBenchmark {

	@Benchmark
	public void longHash_SHA_256() {
		CVMLong l = CVMLong.create(17L);
		AArrayBlob d = Format.encodedBlob(l);
		Hashing.sha256(d.getInternalArray());
	}

	@Benchmark
	public void kilobyteHash() {
		Blob b = Blob.wrap(new byte[1024]);
		b.getHash();
	}

	public static void main(String[] args) throws Exception {
		Options opt = Benchmarks.createOptions(HashBenchmark.class);
		new Runner(opt).run();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy