HomeFreeBSD

test: Optimize operator lookup.

Description

test: Optimize operator lookup.

The linear search using strcmp() shows up in pmcstat for several percent.

Split the operators into lengths and whether they start with '-' and compare
bytes using == instead of strcmp().

A simple test

sh -c 'i=0; w=$(printf %0100d 7); while [ "$i" -lt 1000000 ]; do

v=$(printf %sx%s "$w" "$w"); i=$((i+1)); done'

is over 4% faster on an amd64 bhyve VM.

Details

Provenance
jillesAuthored on
Parents
rS295081: MFhead @ r295080
Branches
Unknown
Tags
Unknown