why use maps for that when a struct { subtotal, total float64 } would work?
Toy examples often don't work because context is important, take a look a Egon's how to ask question (don't have a link sorry). I can think of a few optimisations, but your use case may preclude them, so please give a more complete description of the problem if you can.
Toy examples often don't work because context is important, take a look a Egon's how to ask question (don't have a link sorry).
All in all use struct or slice, not map, for this
But guys really?Don't assume the op has no clue and is stupid.If he needs to use a map he needs to use a map and he has a legitimate question about the performance.
Thanks Dmitry I'll try and rethink the solution design.IRL I've got 1.5million MongoDB documents (hence the use of Maps in the example) with tens of fields in them, all user-definable. The user, through the use of Excel-like formulas, can perform calculations on those fields, say multiply 5 of the 50 fields. So the "real life" process could involve 1.5million iterations over 5 user-defined fields, all multiplied together.
--You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/5tPZhkfDxm8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
Hi Egon,User-defined calculations, using an Excel-like formula language. I suppose an option would be to transpile those formulas (a DSL we've built) into JavaScript compatible with a MongoDB map-reduce.
The prep took 2296ms to run.
The calls took 481ms to run.
The prep took 6.328421182s to run.
The calls took 524.069029ms to run.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
What? The Ruby/JS code he shared each made an array with 10 million maps.
The reason is that properties used (subtotal and total) are both constant and initialised in a fixed order. This means the V8 will generate an "hidden class" for these objects.
I'm also talking about language semantics, not implementation.