2 ms·
While I appreciate the intent, that’s turning beautiful concise code into a very much less readable... thing. How much faster is that?
by jiofih 7y ago
While I appreciate the intent, that’s turning beautiful concise code into a very much less readable... thing.
How much faster is that?
- dwb 7y agoIt would be more polite and accurate to express that as your opinion rather than objective fact. Personally, I prefer to read the second version. I also expect the techniques shown in it, especially parsing against a type-level schema, would be less error-prone than the original in a larger program.
- unlinked_dll 7y agoHaven’t benchmarked but in principle: Serde is one of the fastest deserializers out there. It excels when it has a defined schema to decode, using the #[derive] syntax should offload the work of the deserializer immensely and negate the effects of looking up fields which may not exist. As well, using rust’s iterator adaptors like fold can allow the compiler to make better optimizations for things like summing vectors of floats, such as SIMD/auto vectorizing easier. It’s also better at eliminating or reducing bounds checks. Using iterator abstractions is much more “beautiful” in my opinion to for loops, as well in rust tends to generate better assembly than indexing into collections like slices and vectors.