2 ms·
> The timing went from 8.7 seconds to 6.7 seconds. So all that effort bought a total of a 25% improvement in memory usage and CPU time. AFAIK .NET has a concur
by wahern 8y ago
> The timing went from 8.7 seconds to 6.7 seconds. So all that effort bought a total of a 25% improvement in memory usage and CPU time.
AFAIK .NET has a concurrent garbage collector. For all we know there was a 2nd core running 100% to collect strings that is now almost entirely idle. It's possible the effort more than doubled overall throughput if you consider the ability to run multiple jobs.
That said, ad hoc parsing is a fundamentally messy approach in every language, not just languages like C with poor string handling.[1] Parser generators exist for a good reason--easier to read and great performance without even trying. Find a good one for your language of choice. The learning curve is steep but you'll never look back.
[1] Actually, I find C one of the best languages for parsing as you're much less likely to conflate string manipulation with parsing. Though that realization comes more quickly for some than for others.
- AstralStorm 8y agoWhy are you parsing strings anyway instead of using an efficient binary format with introspection, say, something as simple as Google Protobuf? If the GC is the problem, you can pool the message instances. About the only place where you parse strings is if you're dealing with human input or something almost unstructured like aforementioned CSV.