Benchmarks of common basic operations for the Go language.

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.

Similar Resources

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

Nov 4, 2021

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

Oct 29, 2022

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

Jan 3, 2022

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

Apr 6, 2021

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

Jan 1, 2023

Go Machine Learning Benchmarks

Go Machine Learning Benchmarks

Benchmarks of machine learning inference for Go

Dec 30, 2022

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:

Jan 5, 2023

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

Jan 5, 2023

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

Dec 15, 2022

Benchmarks to compare Go Generics

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

Dec 8, 2022

Sqlbench runs benchmarks on an SQL database

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

Oct 13, 2022

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

Jun 8, 2022

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

Mar 2, 2022

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

Dec 11, 2022

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

Jan 3, 2022

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

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

Jan 29, 2022

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

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

Mar 16, 2022

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

Nov 15, 2022

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.

Jan 8, 2023
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

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:

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

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.

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

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

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

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

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

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

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

Feb 12, 2022