Benchmarks of common basic operations for the Go language.

Overview

gocostmodel

This package was inspired by Brian W. Kernighan and Rob Pike's book "The Practice of Programming" (Addison-Wesley, 1999). In Chapter 7 on performance, section 7.6 (Estimation):

"It's hard to estimate ahead of time how fast a program will be [...]. It's easy, though, to create a cost model for a language or a system, which will give you at least a rough idea of how long important operations take."

This is a cost model that benchmarks common basic operations for the Go language. For it to be meaningful, it should be run on your target hardware, and the relative performance of operations is probably more important than the actual numbers. Examples of such results on a variety of hardware is available in the bench/ folder.

There may be places where compiler optimizations render some benchmarks moot. If you find any such occurrences, please open an issue or send a pull request.

The names of the *_test.go source files should give an idea of the category of operations that are benchmarked.

Example

Here is a short example of benchmark results, run on a Toshiba Chromebook 64-bit running Ubuntu (LXDE) with crouton:

BenchmarkConvIntToFloat64	1000000000	         2.16 ns/op	       0 B/op	       0 allocs/op
BenchmarkConvFloat64ToInt	2000000000	         1.26 ns/op	       0 B/op	       0 allocs/op
BenchmarkConvIntToFloat32	2000000000	         1.44 ns/op	       0 B/op	       0 allocs/op
BenchmarkConvFloat32ToInt	2000000000	         1.42 ns/op	       0 B/op	       0 allocs/op
BenchmarkConvStringToInt	30000000	        57.8 ns/op	       0 B/op	       0 allocs/op
BenchmarkConvIntToString	20000000	       108 ns/op	       1 B/op	       1 allocs/op
BenchmarkStringToByte	20000000	       110 ns/op	       8 B/op	       1 allocs/op
BenchmarkByteToString	20000000	        84.8 ns/op	       4 B/op	       1 allocs/op
BenchmarkFindSliceInt5	100000000	        13.0 ns/op	       0 B/op	       0 allocs/op
BenchmarkFindSliceStr5	20000000	        64.9 ns/op	       0 B/op	       0 allocs/op
BenchmarkFindSliceInt100	10000000	       236 ns/op	       0 B/op	       0 allocs/op
BenchmarkFindSliceStr100	 1000000	      1248 ns/op	       0 B/op	       0 allocs/op
BenchmarkFindMapInt5	100000000	        22.2 ns/op	       0 B/op	       0 allocs/op
BenchmarkFindMapStr5	20000000	        77.6 ns/op	       0 B/op	       0 allocs/op
BenchmarkFindMapInt100	30000000	        58.3 ns/op	       0 B/op	       0 allocs/op
BenchmarkFindMapStr100	20000000	        76.2 ns/op	       0 B/op	       0 allocs/op
BenchmarkFloat32Assign	2000000000	         0.99 ns/op	       0 B/op	       0 allocs/op

Installation

$ go get github.com/PuerkitoBio/gocostmodel

Running the benchmarks

$ go test -run zz -bench . [-benchmem]

Contributing

Pull requests are welcome, but the benchmarks should be for common basic operations, in the spirit of the existing benchmarks.

License

This source code is released under the BSD 3-clause license.

You might also like...
Minimalistic library for basic matrix operations.

MATRIX Maybe a bit slow, but minimalistic library for basic matrix operations. Available functions Function signature Description Equal(a, b [][]float

Beerus-DB: a database operation framework, currently only supports Mysql, Use [go-sql-driver/mysql] to do database connection and basic operations

Beerus-DB · Beerus-DB is a database operation framework, currently only supports Mysql, Use [go-sql-driver/mysql] to do database connection and basic

Api-product - A basic REST-ish API that allows you to perform CRUD operations for Products

Description A basic REST-ish API that allows you to perform CRUD operations for

cmd tool for automatic storage and comparison of benchmarks results

prettybenchcmp prettybenchcmp is cmd tool for storage and comparison of benchmarks results. There is a standard tool benchcmp, but I don't think that

Benchmarks of Go serialization methods

Benchmarks of Go serialization methods This is a test suite for benchmarking various Go serialization methods. Tested serialization methods encoding/g

Go Machine Learning Benchmarks
Go Machine Learning Benchmarks

Benchmarks of machine learning inference for Go

benchmarks for implementation of servers which support 1 million connections

Benchmark for implementation of servers that support 1m connections inspired by handling 1M websockets connections in Go Servers 1_simple_tcp_server:

Robust framework for running complex workload scenarios in isolation, using Go; for integration, e2e tests, benchmarks and more! 💪

e2e Go Module providing robust framework for running complex workload scenarios in isolation, using Go and Docker. For integration, e2e tests, benchma

A scanner for running security-related configuration checks such as CIS benchmarks

Localtoast Localtoast is a scanner for running security-related configuration checks such as CIS benchmarks in an easily configurable manner. The scan

Benchmarks to compare Go Generics

This is a collection of various sorts implemnted both as []int only and as const

Sqlbench runs benchmarks on an SQL database

sqlbench runs benchmarks on an SQL database. Right now this works for PostgreSQL

Cloud-Z gathers information and perform benchmarks on cloud instances in multiple cloud providers.

Cloud-Z Cloud-Z gathers information and perform benchmarks on cloud instances in multiple cloud providers. Cloud type, instance id, and type CPU infor

An operator that helps you perform benchmarks

Camunda-Benchmark-Operator 🏋️‍♀️ An operator that helps you perform benchmarks. Your first benchmark This requires that you know how to run the opera

Advanced benchmarks for +15 Go ORMs.

Go ORM Benchmarks Advanced benchmarks for +10 Go ORMs. Originally forked from orm-benchmark. ORMs All package run in no-cache mode. beego/orm bun gorm

Basic-api-with-go - A basic api with golang

I am creating my first API with GO. Install go get -u github.com/Yefhem/basic-ap

Go-basic-graphql - Basic implementation of GraphQL using Go

Go-basic-graphql - Basic implementation of GraphQL using Go

Go-basic-skeleton - Simple and basic skeleton for go projects

Go Bootstrap (base/skeleton) Introduction This is a repository intended to serve

a decision & trigger framework backed by Google's Common Expression Language used in graphikDB

a decision & trigger framework backed by Google's Common Expression Language used in graphikDB

Common Expression Language -- specification and binary representation

The Common Expression Language (CEL) implements common semantics for expression evaluation, enabling different applications to more easily interoperate.

Owner
Martin Angers
Martin Angers
Benchmarks of Go serialization methods

Benchmarks of Go serialization methods This is a test suite for benchmarking various Go serialization methods. Tested serialization methods encoding/g

Alec Thomas 1.4k Jan 1, 2023
benchmarks for implementation of servers which support 1 million connections

Benchmark for implementation of servers that support 1m connections inspired by handling 1M websockets connections in Go Servers 1_simple_tcp_server:

smallnest 1.7k Jan 5, 2023
Compare various Image resize algorithms for the Go language

speedtest-resize Compare various Image resize algorithms for the Go language I am writing a web gallery called gonagall in Go (https://github.com/fawi

Fabian Wickborn 228 Dec 8, 2022
🔥 Golang Rest Api with basic JWT Authentication and Basic Crud Operations.

?? Golang Rest Api with basic JWT Authentication and Basic Crud Operations.

Junaid Javed 19 Oct 4, 2022
subtraction operations and also parentheses to indicate order of operations

basic parsing expose a Calculate method that accepts a string of addition / subtraction operations and also parentheses to indicate order of operation

Michael Street 0 Feb 22, 2022
Distributed File Store Application Consist of API Server to handle file operations and command line tool to do operations

Filestore Distributed File Store Application Consist of API Server to handle file operations and command line tool to do operations (store named binar

null 0 Nov 7, 2021
Go micro-benchmarks for calculating the speed of language constructs

== About == Gospeed is a library of micro-benchmarks for Go which evolved from the GoLightly project. It's main utility is for understanding and reas

Eleanor McHugh 110 Sep 27, 2022
redis-util business-friendly encapsulation of redis operations, such as the common cache set get operation

redis-util 方便业务使用的redis操作封装,比如常见的缓存set get操作, 一行代码搞定,不像开源库需要写好多行 使用方法

connor 1 Oct 22, 2021
Common case conversions covering common initialisms.

kace go get "github.com/codemodus/kace" Package kace provides common case conversion functions which take into consideration common initialisms. Usag

Code Modus 19 Sep 27, 2022
Turbine-common - This package contains the common interfaces for Turbine that are shared with other software

turbine-common This package contains the common interfaces for Turbine that are

NoraSector 3 Feb 12, 2022