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

decoder2: decode bool and numbers #22550

Merged
merged 5 commits into from
Oct 17, 2024

Conversation

enghitalo
Copy link
Contributor

@enghitalo enghitalo commented Oct 17, 2024

feature example

json.decode[int]('1234567890')!

benchmark

Starting benchmark...
max_iterations: 1000000

***Structure and maps***
 SPENT   331.243 ms in old_json.decode(Stru, json_data)!

 SPENT   121.179 ms in decoder2.decode[StructType[string]](json_data1)!
 SPENT    85.539 ms in old_json.decode(StructType[string], json_data1)!

 SPENT   133.756 ms in decoder2.decode[StructTypeOption[string]](json_data1)!
 SPENT    83.031 ms in old_json.decode(StructTypeOption[string], json_data1)!

 SPENT   119.793 ms in decoder2.decode[StructType[int]](json_data2)!
 SPENT    84.340 ms in old_json.decode(StructType[int], json_data2)!

 SPENT   115.752 ms in decoder2.decode[map[string]string](json_data1)!
 SPENT   195.674 ms in old_json.decode(map[string]string, json_data1)!


***simple types***
 SPENT    24.796 ms in decoder2.decode[int]('2')!
 SPENT    25.352 ms in decoder2.decode[bool]('true')!

@enghitalo enghitalo changed the title Jso2/new decode2 rewrite decoder2: decode bool and numbers Oct 17, 2024
// string_buffer_to_generic_number converts a buffer of bytes (data) into a generic type T and
// stores the result in the provided result pointer.
// The function supports conversion to the following types:
// - Signed integers: i8, i16, int, i64
Copy link
Contributor

Choose a reason for hiding this comment

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

May want to make this i8, i16, i32, i64 since int is supposed to change in the future... it will be 32 bits on 32 bit systems, and 64 bits on 64 bit systems.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good find. I will change it in next PR to avoid rerun CI

Copy link
Contributor

Choose a reason for hiding this comment

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

Heh. CI is less that halfway done.

@spytheman spytheman merged commit 7c1cde0 into vlang:master Oct 17, 2024
67 checks passed
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.

4 participants