bound

package
v0.0.0-...-ded6a28 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2024 License: BSD-3-Clause Imports: 0 Imported by: 0

Documentation

Overview

Package bound is a simple benchmark of the x86 BOUND instruction. Spoiler alert. It's slow.

Results

On my MacBook Pro (Intel Core i5-3210M @ 2.50 GHz), using BOUND is 9x slower than using CMP after you subtract out the cost of the benchmark loop:

g% 386 go test -bench . -benchtime 10s
testing: warning: no tests to run
PASS
BenchmarkNop	1000000000	         0.33 ns/op
BenchmarkBound	1000000000	         3.35 ns/op
BenchmarkCmp	1000000000	         0.66 ns/op
BenchmarkCmpReg	1000000000	         0.67 ns/op
ok  	rsc.io/tmp/bound	9.147s
g%

Maybe someone familiar with the CPU architecture of the Core i5 can explain to me why I have a 2.50 GHz clock speed but instruction retirement seems to be running at 3 GHz.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL