ChakraCore is the core part of the Chakra Javascript engine that powers Microsoft Edge
wyrichte on ADO_test
Update ChakraCoreStatic.cpp (compare)
wyrichte on Test-PR-webhook---don't-merge
Update ChakraCoreStatic.cpp (compare)
wyrichte on Test-PR-webhook---don't-merge
Update ChakraCoreStatic.cpp (compare)
new Function()
have worse runtime performance (by a factor of, it seems, ~3-4x) than an equivalent function defined in the source code? I know eval
'd code is slower because it needs to add extra instructions into the bytecode to capture completion values but I wasn't expecting new Function()
to be slower too
Probably depends on the function? I just did
var y = 0
function foo() {
var x = 1
var z = y + x
return z
}
var bar = new Function([], `var x = 1
var z = y + x
return z`);
foo();
bar();
and looked at the bytecode, and foo and bar were identical. Are you doing more complex things with "arguments" or "super" or anything?
arguments
or anything, just a basic JS function with a for
loop in it
new Function
'd code is treated in the same way as eval, as dynamic code, while code passed as a script file is treated differently, it may be that the jit treats them differently.
Basically if I have a query that looks like
from(array).where(n => n % 2 === 0).select(n => n * 8).reduce((a, n) => a + n, 0);
that gets "jitted" to a function which is called to actually run the query
((array, filter0, map1, reducer, acc) => {
for (let i = 0, len = array.length; i < len; ++i) {
value = array[i];
if (!filter0(value)) continue;
value = map1(value);
acc = reducer(acc, value);
}
return acc;
})
require
it in, it's fast. Passing the same exact source code to new Function
is slower by a factor of 3-4
Following up on the query compiler system I discussed above, I've implemented it and now my built-in from()
beats everyone else's functional libraries by a comfortable margin :smile:
const arr = /* 100K random floats between 0-1000 */;
from(arr)
.where(n => n < 500)
.take(100)
.select(n => Math.floor(n))
.plus("rando string")
.shuffle()
.count(it => typeof it);
Benchmarking results:
event count time (us) % run avg (us) % avg |
--------------------------------------------------------------------
Underscore _.chain() 1,001 2,398,028 93.7 % 2,395 95.3 % |
Lodash _.chain() 1,001 43,649 1.7 % 43 1.7 % |
from.js 1.0 1,001 38,226 1.5 % 38 1.5 % |
Lazy.js Lazy() 1,001 21,433 0.8 % 21 0.9 % |
from() (mS 5.3+) 1,001 15,326 0.6 % 15 0.6 % |
references
of your projects?
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Allegro" version="5.2.4.0" targetFramework="native" />
<package id="AllegroDeps" version="1.7.0.0" targetFramework="native" />
<package id="Microsoft.ChakraCore.vc140" version="1.11.3" targetFramework="native" developmentDependency="true" />
</packages>
.sln
+ all .*proj
files in the same directory and MSVC generally seems to prefer one .vcxproj per directory