Skip to content

x/perf/benchfmt: output an error in case the input file is not utf8 encoded #58579

Open
golang/perf
#9
@phenpessoa

Description

@phenpessoa

Related to: #58576

Currently, if a benchmark file is encoded in utf16 (which is the default in windows), the benchstat tool will fail silently. This might be hard to debug to the end user.

I propose that instead of failing silently, the tool should return an error letting the user know their file is not properly encoded.

On windows, running this command: go test -bench . -count 10 > old.txt will return a utf16 encoded file by default.

It is a simple change, after this line, we just need to add something like:

if !utf8.Valid(line) {
	r.err = fmt.Errorf("%s: invalid encode, only utf8 encoded files are supported", r.result.fileName)
	return false
}

And then if the user were to run the benchstat tool, they would get that error instead of it failing silently.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions