Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8_11] boost performance of api converting number to hexadecimal string #329

Merged
merged 3 commits into from
Jun 6, 2024

Conversation

jingkaimori
Copy link
Contributor

@jingkaimori jingkaimori commented Jun 6, 2024

Performance

to_hex faster 50%, as_hexadecimal faster 82%!!!

Before

complexityN ns/op op/s err% total benchmark
1 3.03 329,610,514.51 2.3% 0.02 convert hexadecimal string to int
1 12.77 78,320,857.02 1.9% 0.06 convert signed int to hexadecimal string
1 13.15 76,026,752.24 1.1% 0.06 convert unsigned int to hexadecimal string
2 3.91 255,599,303.35 4.7% 0.02 convert hexadecimal string to int
2 12.69 78,811,782.13 1.0% 0.06 convert signed int to hexadecimal string
2 47.51 21,049,513.78 2.8% 0.23 convert unsigned int to hexadecimal string
3 4.85 206,384,036.36 1.6% 0.02 convert hexadecimal string to int
3 12.81 78,044,226.04 0.7% 0.06 convert signed int to hexadecimal string
3 74.44 13,434,353.45 0.7% 0.36 convert unsigned int to hexadecimal string
4 5.88 170,029,870.91 2.3% 0.03 convert hexadecimal string to int
4 48.58 20,584,946.78 3.1% 0.24 convert signed int to hexadecimal string
4 108.33 9,231,414.46 0.5% 0.52 convert unsigned int to hexadecimal string
5 6.70 149,337,147.16 0.5% 0.03 convert hexadecimal string to int
5 48.16 20,763,956.26 1.3% 0.23 convert signed int to hexadecimal string
5 148.89 6,716,357.71 0.2% 0.72 convert unsigned int to hexadecimal string

After

complexityN ns/op op/s err% total benchmark
1 2.95 339,258,986.45 0.8% 0.02 convert hexadecimal string to int
1 17.74 56,374,077.33 1.5% 0.08 convert signed int to hexadecimal string
1 14.38 69,547,781.82 0.9% 0.07 convert unsigned int to hexadecimal string
2 3.94 253,905,312.41 3.4% 0.02 convert hexadecimal string to int
2 17.42 57,406,505.14 1.2% 0.08 convert signed int to hexadecimal string
2 15.57 64,211,588.80 0.6% 0.08 convert unsigned int to hexadecimal string
3 5.76 173,703,719.01 2.6% 0.03 convert hexadecimal string to int
3 17.49 57,190,688.69 1.1% 0.09 convert signed int to hexadecimal string
3 17.21 58,097,326.85 1.3% 0.08 convert unsigned int to hexadecimal string
4 5.89 169,673,236.32 2.5% 0.03 convert hexadecimal string to int
4 21.83 45,811,805.23 1.0% 0.11 convert signed int to hexadecimal string
4 19.27 51,898,451.76 1.4% 0.09 convert unsigned int to hexadecimal string
5 6.73 148,631,690.89 1.9% 0.03 convert hexadecimal string to int
5 22.18 45,085,309.87 1.1% 0.11 convert signed int to hexadecimal string
5 22.65 44,143,155.21 0.4% 0.11 convert unsigned int to hexadecimal string

@jingkaimori jingkaimori requested a review from da-liii June 6, 2024 12:48
@da-liii da-liii changed the title boost performance of api converting number to hexadecimal string [8_11] boost performance of api converting number to hexadecimal string Jun 6, 2024
Copy link
Contributor

@da-liii da-liii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@da-liii da-liii merged commit e20b546 into main Jun 6, 2024
12 checks passed
@da-liii da-liii deleted the jingkaimori/numeral_performance branch June 6, 2024 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants