I get an error with v8: '3.11.10.25': 
FATAL ERROR: v8::Object::SetIndexedPropertiesToExternalArrayData() JSArray 
is not supported

Now I am trying this option:
GetPointerFromInternalField<http://izs.me/v8-docs/classv8_1_1Object.html#a8ef1f3e0d4f4cecc54d5e0248bc45694>
 (int 
index)

On Wednesday, April 30, 2014 12:13:26 PM UTC+2, Ben Noordhuis wrote:
>
> On Wed, Apr 30, 2014 at 11:10 AM, Kees k <[email protected]<javascript:>> 
> wrote: 
> > Hello all, 
> > 
> > I am writing a piece of code to interface with a modbus library 
> > (libmodbus),which should be really fast. One bottleneck is that I have 
> to 
> > convert a Local<Array> to uint8_t array: 
> > 
> >>> uint8_t req[req_length]; 
> >>> Local<Array> req_arr = Local<Array>::Cast(args[1]); 
> >>> struct timespec tstart, tstop; 
> >>> clock_gettime(CLOCK_MONOTONIC, &tstart); 
> >>> for (int i = 0; i < req_length; i++) { 
> >>>     req[i] = req_arr->Get(i)->Uint32Value(); 
> >>> } 
> >>> clock_gettime(CLOCK_MONOTONIC, &tstop); 
> > 
> > According to benchmarks this piece of code takes about 1 ms with a 
> > req_length of 80 on a Beaglebone Black (1 MHz), which really surprises 
> me. 
> > After some digging I found that the conversion 'Uint32Value()' consumes 
> most 
> > of the time. After leaving out this conversion the benchmark results in 
> 100 
> > usec. 
> > 
> > Does anyone have an idea to improve the performance of this simple 
> > 'Uint32Value' conversion? 
>
> Maybe try switching to 
> v8::Object::SetIndexedPropertiesToExternalArrayData() with type 
> kExternalUint32Array.  That lets you construct a typed array without 
> going through (much of) the typed array machinery. 
>
>   void Create(const FunctionCallbackInfo<Value>& args) { 
>     HandleScope handle_scope(args.GetIsolate()); 
>     Local<Object> obj = args[0]->ToObject(); 
>     uint32_t nelts = args[1]->Uint32Value(); 
>     uint32_t* elts = new uint32_t[nelts]; 
>     obj->SetIndexedPropertiesToExternalArrayData(elts, 
> kExternalUint32Array, nelts); 
>   } 
>
>   void Process(const FunctionCallbackInfo<Value>& args) { 
>     HandleScope handle_scope(args.GetIsolate()); 
>     Local<Object> obj = args[0]->ToObject(); 
>     void* data = obj->GetIndexedPropertiesExternalArrayData(); 
>     if (data == NULL) return; 
>     uint32_t* elts = static_cast<uint32_t*>(data); 
>     uint32_t nelts = obj->GetIndexedPropertiesExternalArrayDataLength(); 
>     // Process the data. 
>   } 
>
> Note that you need to take care of releasing the memory again when 
> you're done with it.  Either do that manually or turn the object into 
> a weak persistent handle and release the memory in your weak callback. 
>
> You can also use the typed array API in v8.h but that's only available 
> in node.js master.  (Writing that I realized I used the V8 3.25 API in 
> the example above; the gist of it is the same in v0.10, however.) 
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" 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.

Reply via email to