-
Notifications
You must be signed in to change notification settings - Fork 32
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
Use InlineArray
for cache
to match C
#67
base: master
Are you sure you want to change the base?
Conversation
b58ede8
to
11569dc
Compare
Running this version of code on the mojo playground is slower than main_v2.mojo. |
On my Mac 2 Pro laptop, i get nearly identical performance results: List / UInt32 version:
InlineArray / UInt32 version (this PR)
Would love to see benchmark results of these two on other devices. |
I'm not that concerned with performance (I know they should be roughly identical, for the generated assembly says so). This PR is more to showcase how to write such a program using arrays. BTW, try running this benchmark script. |
Thanks for the script: I get
;-) |
see my comment about the benchmark, it is not so straightforward a change |
Why is it necessary to modify v1? |
@jabbalaci it's just the code formatter that mojo uses. If you run |
@jabbalaci I just wanted to minimise unrelated differences so that comparing the two files in a diff view would be clearer. And in order to avoid my own bias in coding style, I used the default code formatter. If you prefer not to include the cosmetic changes to v1, I can revert them. |
A |
- Make type (defaults to `UInt32`) an alias - Use `InlineArray` instead of `List` for cache, remove bound check - Format code using `mblack` (official code formatter with default settings)
@jabbalaci Good catch. Fixed. |
In my machine it seems like the Doing a global var cache and passing it as a function argument to
Doing a local alias cache inside the function
See PR #68 for more benchmark results in my machine |
I think it's a good example of progressive disclosure of complexity.
UInt32
) an aliasInlineArray
instead ofList
for cache, remove bound checkmblack
(official Mojo code formatter with default settings)