Example #1
0
File: main.go Project: catgatp/gol
func main() {
	var (
		std_json, gol_encodejson, gol_encodejsonFast testing.BenchmarkResult
		operation_name                               string
	)

	operation_name = "Encode"
	std_json = testing.Benchmark(Benchmark_std_json)
	gol_encodejson = testing.Benchmark(Benchmark_gol_encodejson)
	gol_encodejsonFast = testing.Benchmark(Benchmark_gol_encodejsonFast)
	fmt.Print(operation_name, "\n", "std_json:", std_json, std_json.MemString(),
		"\n", "gol_encodejson:", gol_encodejson, gol_encodejson.MemString(),
		"\n", "gol_encodejsonFast:", gol_encodejsonFast, gol_encodejsonFast.MemString(), "\n")

}
Example #2
0
func benchString(r testing.BenchmarkResult) string {
	nsop := r.NsPerOp()
	ns := fmt.Sprintf("%10d ns/op", nsop)
	allocs := "0"
	if r.N > 0 {
		if nsop < 100 {
			// The format specifiers here make sure that
			// the ones digits line up for all three possible formats.
			if nsop < 10 {
				ns = fmt.Sprintf("%13.2f ns/op", float64(r.T.Nanoseconds())/float64(r.N))
			} else {
				ns = fmt.Sprintf("%12.1f ns/op", float64(r.T.Nanoseconds())/float64(r.N))
			}
		}

		allocs = fmt.Sprintf("%d", r.MemAllocs/uint64(r.N))
	}

	return fmt.Sprintf("%8d\t%s\t%s allocs", r.N, ns, allocs)
}
Example #3
0
File: main.go Project: catgatp/gol
func main() {
	var (
		rcache, rgo_cache testing.BenchmarkResult
		operation_name    string
	)

	operation_name = "Set"
	rcache = testing.Benchmark(Benchmark_cacheSet)
	rgo_cache = testing.Benchmark(Benchmark_gocacheSet)
	fmt.Print(operation_name, "\n", "Cergoo.cache:", rcache, rcache.MemString(), "\n", "go-cache:    ", rgo_cache, rgo_cache.MemString(), "\n")
	operation_name = "Get"
	rcache = testing.Benchmark(Benchmark_cacheGet)
	rgo_cache = testing.Benchmark(Benchmark_gocacheGet)
	fmt.Print(operation_name, "\n", "Cergoo.cache:", rcache, rcache.MemString(), "\n", "go-cache:    ", rgo_cache, rgo_cache.MemString(), "\n")
	operation_name = "Inc"
	rcache = testing.Benchmark(Benchmark_cacheInc)
	rgo_cache = testing.Benchmark(Benchmark_gocacheInc)
	fmt.Print(operation_name, "\n", "Cergoo.cache:", rcache, rcache.MemString(), "\n", "go-cache:    ", rgo_cache, rgo_cache.MemString(), "\n")
}
Example #4
0
File: main.go Project: catgatp/gol
func main() {
	var (
		binaryEDt, fastEDt, gobt testing.BenchmarkResult
		operation_name           string
	)

	operation_name = "Encode"
	binaryEDt = testing.Benchmark(Benchmark_BinaryED_Encode)
	fastEDt = testing.Benchmark(Benchmark_FastED_Encode)
	gobt = testing.Benchmark(Benchmark_gob_Encode)
	fmt.Print(operation_name, "\n", "binaryED:", binaryEDt, binaryEDt.MemString(), "\n", "fastED:", fastEDt, fastEDt.MemString(), "\n", "gob:", gobt, gobt.MemString(), "\n")
	operation_name = "Decode"
	binaryEDt = testing.Benchmark(Benchmark_BinaryED_Decode)
	fastEDt = testing.Benchmark(Benchmark_FastED_Decode)
	gobt = testing.Benchmark(Benchmark_gob_Decode)
	fmt.Print(operation_name, "\n", "binaryED:", binaryEDt, binaryEDt.MemString(), "\n", "fastED:", fastEDt, fastEDt.MemString(), "\n", "gob:", gobt, gobt.MemString(), "\n")

}