what is going on with the m4 code?
what is going on with the m4 code?
(use std::borrow::Cow;) ?!
(I don't know rust, its on my list.. Especially with cow borrowing! They clearly are my people).
I noticed they added a comparison of Rust to gnu yes on the thread. They only got: 2.17GiB/s but on a slower machine.. (2.04 for the GNU)
In that Rust program, Cow is being used here so if the user provides an argument it ends up with an owned vector that contains that argument plus a newline, otherwise it ends up with a borrowed byte slice that contains "y\n". That said, there's not really a whole lot of point to using Cow here since allocation is a one-time cost and nobody cares if yes starts up a few microseconds slower, but the usage of Cow is limited to just a couple of lines so it's not really complicating anything (the actual write() call just ends up taking a &[u8] byte slice, so the usage of Cow is strictly limited to main()).
Also, I didn't realize it was Clone-on-write. Interesting, and the documentation does confirm this. I say "interesting" because the actual operation involved is `to_owned()`, not `clone()`, seeing as how `clone()` on a `&str` just gives you the same `&str` back.
[1]: https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpris...
Remember this is without any printing: C is fast, if I remember correctly it was something like 0.015 or 0.03s while at the other end of the spectrum I had to wait 0.1s for JavaScript. C results varied from simple to double because of the OS I guess because it was so quick.
It isn't a really significant benchmark though, for any language. It was one of those nights. Ah, and I remember a large difference between go run and go install.
Sure, but it's reassuring to know that the universe is still sane, C is still faster than Javascript.
Thanks for expanding on your comment!
c 0.062s
f90 0.080s
go 0.108s
awk 0.116s
lua 0.117s
rs 0.140s
sh 0.434s
php 0.886s
scm 1.323s
py 2.965s
rb 3.738s
js 5.411s
My memory was bad, I also added fortran for the occasion.