Fix benchmark script replacing internal package imports (#1042)
* Fix benchmark script replacing internal package imports The sed command in bench() was replacing all occurrences of the go-toml module path, including sub-package imports like internal/assert. This caused the BurntSushi/toml benchmark to fail because it tried to import github.com/BurntSushi/toml/internal/assert which doesn't exist. Fix by anchoring the sed pattern to only match the import path when followed by a closing quote, preserving internal package imports. Also add a guard in the benchstathtml Python script to give a clear error instead of an IndexError when no benchmark results are available. https://claude.ai/code/session_016JGASo49PeFSfCaDxvrGFE * Update benchmark results in README https://claude.ai/code/session_016JGASo49PeFSfCaDxvrGFE --------- Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -147,7 +147,7 @@ bench() {
|
||||
pushd "$dir"
|
||||
|
||||
if [ "${replace}" != "" ]; then
|
||||
find ./benchmark/ -iname '*.go' -exec sed -i -E "s|github.com/pelletier/go-toml/v2|${replace}|g" {} \;
|
||||
find ./benchmark/ -iname '*.go' -exec sed -i -E "s|github.com/pelletier/go-toml/v2\"|${replace}\"|g" {} \;
|
||||
go get "${replace}"
|
||||
fi
|
||||
|
||||
@@ -195,6 +195,11 @@ for line in reversed(lines[2:]):
|
||||
"%.1fx" % (float(line[3])/v2), # v1
|
||||
"%.1fx" % (float(line[7])/v2), # bs
|
||||
])
|
||||
|
||||
if not results:
|
||||
print("No benchmark results to display.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
# move geomean to the end
|
||||
results.append(results[0])
|
||||
del results[0]
|
||||
|
||||
Reference in New Issue
Block a user