On Tue, Nov 28, 2017 at 9:50 AM, <[email protected]> wrote: > Hi. > > I have big unordered_map in C++, like > > std::unordered_map<uint32_t, MyObject>; > > It contains more than 10 million elements, and i need about 10 thousand hits > to map from js. What is the most productive way to pass it to JS? > > 1) I can add each item to v8 variable: > > v8::Local<v8::Object> map; > map.Set(context, key, value); > > But how productive it will be? And what type of v8::Object i must use? > (v8::Object or v8::Map)? > > 2) I can use NamedProperty, but each access to map from js will call my c++ > func. It's now slow? > > And what kind of named properties should I must use in this variant? I see > at least (SetAccessor, SetNamedPropertyHandler, SetHandler from > v8::ObjectTemplate) and (SetAccessor, SetAccessorProperty, > SetNativeDataProperty from v8::Object)
I would recommend to benchmark both approaches and see for yourself. Intuitively, I would say that an accessor is going to be faster because the number of lookups is much smaller than the number of keys, but performance characteristics are frequently counter-intuitive. -- -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
