Skip to content

Buffer.byteLength benchmark does not test base64 encoding correctly #60836

Description

@kisugez

Version

Output of node -v: (e.g. v20.10.0)

Platform

Output of uname -a (for UNIX) or Windows version string (for Windows).

Subsystem

buffers (benchmark/buffers/buffer-bytelength-string.js)

What steps will reproduce the bug?

Run the buffer byteLength benchmark for base64 encoding.
Expected: getInput should return a base64-encoded string when encoding is 'base64'.
Actual: getInput returns the original string, not the base64-encoded string.

How often does it reproduce? Is there a required condition?

Run the buffer byteLength benchmark for base64 encoding.
Expected: getInput should return a base64-encoded string when encoding is 'base64'.
Actual: getInput returns the original string, not the base64-encoded string.

What is the expected behavior? Why is that the expected behavior?

getInput should return the base64-encoded string so the benchmark accurately tests Buffer.byteLength for base64 input.

What do you see instead?

The benchmark tests the original string, not the base64-encoded string.

Additional information

Suggested fix:
In benchmark/buffers/buffer-bytelength-string.js, update getInput to return Buffer.from(original, 'utf8').toString('base64') when encoding is 'base64'.
This will ensure the benchmark is correct.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions