Monday, March 21, 2016

determining throughput speed Cordova bridge. Any insights?

Leave a Comment

I'm trying to get an idea about the throughput speed of Cordova's WebView-Native bridge. For this I will send a Uint8Array of a determined size. However, I would have expected the throughput speed of this bridge to be higher.

Testing on a iPhone 4s and Cordova 5.4.1 the throughput speed is ~0.8mb/s. This feels low to me (based on some experience with Cordva apps, but this is of course subjective).

Question: is this realistic?

I think that without posting my code this questions show no enough info, therefore I've attached my code:

My JavaScript code:

var success = function(endTime) {     //endTime is unix epoch time (ms)     var time_df = endTime - beginTime     results.push(time_df)     numTests += 1;     sendMessage() }  var sendMessage = function() {     // execute test 30 times     if (numTests < 30) {         beginTime = +new Date()         bench.send(payload, success, fail)     } else {         console.log('results', results)     } } var createPayload = function(size) {     size = size * 1000;     var bufView = new Uint8Array(size);     for (var i = 0; i < size; ++i) {         bufView[i] = i % 20;     }     return bufView.buffer; }  var startTest = function() {     // create payload of 500kb     payload = createPayload(500)     sendMessage() } 

My Objective-C code. Code does basicly one thing: return unix epoch time after payload is received.

(void)send:(CDVInvokedUrlCommand*)command {     NSTimeInterval time = ([[NSDate date] timeIntervalSince1970]); // returned as a double    long digits = (long)time; // this is the first 10 digits    int decimalDigits = (int)(fmod(time, 1) * 1000); // this will get the 3 missing digits    long timestamp = (digits * 1000) + decimalDigits;    NSString *timestampString = [NSString stringWithFormat:@"%ld%d",digits ,decimalDigits];      NSString* callbackId = [command callbackId];      CDVPluginResult* result = [CDVPluginResult                                resultWithStatus:CDVCommandStatus_OK                                messageAsString:timestampString];      [self success:result callbackId:callbackId]; } 

0 Answers

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment