Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
bouncing_ball(1., 0.5, 0.25)
will return 5 instead of 3 herethis is a thousand times slower than it could be
Haha, seems correct 🙈
When I run your benchmark with a 10M random file, I get 307.73ms, 37.92ms and 74.46ms, which is close to what I had. However, when I run it without
--release
, I get 7.26s, 319.00ms, 206.36ms, which is similar to your result. So maybe you were missing the compiler optimizations?I wasn't actually very experienced at this stuff, so I used plain
std::time
and manually ran the code multiple times to check the variance. Benchmarkingprintln!("Answer: {}", answer);
looks very weird, but I probably didn't know aboutblack_box
and needed to make sure that the code actually did the work.I don't remember why I saved a fixed generated string to disk. I don't have the code that generated it, but I still have
string.txt
. It looks like it was the sameb".-=<>".choose(&mut rng)
, but 10 MB in size rather than 1 KiB.On my current machine, here are the timings from this bench:
The speedup is still 84x, even though I'm on a different machine now
In my benchmark I get:
Here I see a 10x boost instead of a 90x boost.
So may I know how your benchmark is organized?
Mine is as follows:
Cool and tricky
Nice. There is a typo though: in emit_instructions_recursive you have PO instead of PU. Also,
move_immediate_to_rhs
can swap the operands of division or subtraction.Ah, hence the inline.
I was wondering what it was for, thanks :)
I guess the compiler automatically changes 21**n in the result.
It simplifies the code, of course, but it also makes it about 8 times slower.
Exponentiation is a difficult operation, I made it faster by introducing a 10 element table of precomputed powers.
what the hell
Cool!
Just wanted to point it out, since it was the most upvoted solution.
Yes, but it's 8 kyu. You can't expect questions on data size limits on 8 kyu.
Probably there should be something like n <= 1_000_000_000 in the description to avoid ambiguity.
Panics!
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=a63ebb85f52e1417236a6dcb40bd6bb5
Check out the improved version (the fork). It's 15 times faster than the
format!
way.Loading more items...