I was just profiling some code that uses ref-struct to parse a binary log file and was finding several locations where I accessed fields on a struct instance were showing up as hot spots. Further digging points to this assertion statement:
assert(rtn && 'size' in rtn && 'indirection' in rtn
, 'could not determine a proper "type" from: ' + JSON.stringify(type))
Though the assertion is never failing in my case, the code was doing a lot of work to generate the error message anyway and that work was really adding up over time.
Changing the asserts to:
if (!(rtn && 'size' in rtn && 'indirection' in rtn)) {
assert(false, 'could not determine a proper "type" from: ' + JSON.stringify(type))
}
...sped up parsing time for a file with 180K events from 16 to 8 seconds.
I may still wind up changing to manual (or even native) parsing for extra speed, but the ref/struct/ffi libraries have been so useful I wanted to take the time to pass along a report. I could send the change as a pull request, too if the change looks satisfactory.
I was just profiling some code that uses ref-struct to parse a binary log file and was finding several locations where I accessed fields on a struct instance were showing up as hot spots. Further digging points to this assertion statement:
Though the assertion is never failing in my case, the code was doing a lot of work to generate the error message anyway and that work was really adding up over time.
Changing the asserts to:
...sped up parsing time for a file with 180K events from 16 to 8 seconds.
I may still wind up changing to manual (or even native) parsing for extra speed, but the ref/struct/ffi libraries have been so useful I wanted to take the time to pass along a report. I could send the change as a pull request, too if the change looks satisfactory.
Thanks.