Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix string.split and array.join performance #462

Merged
merged 1 commit into from Jan 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
74 changes: 74 additions & 0 deletions Jint.Benchmark/DromaeoBenchmark.cs
@@ -0,0 +1,74 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Jobs;
using Jint;

namespace Esprima.Benchmark
{
[Config(typeof(Config))]
[MemoryDiagnoser]
public class DromaeoBenchmark
{
private class Config : ManualConfig
{
public Config()
{
// if Jint array performance gets better we can go towards defaul 16/16
Add(Job.ShortRun.WithInvocationCount(4).WithUnrollFactor(4));
}
}

private static readonly Dictionary<string, string> files = new Dictionary<string, string>
{
{"dromaeo-3d-cube", null},
{"dromaeo-core-eval", null},
{"dromaeo-object-array", null},
{"dromaeo-object-regexp", null},
{"dromaeo-object-string", null},
{"dromaeo-string-base64", null}
};

private Engine engine;

[GlobalSetup]
public void Setup()
{
foreach (var fileName in files.Keys.ToList())
{
files[fileName] = File.ReadAllText($"Scripts/dromaeo/{fileName}.js");
}

engine = new Engine()
.SetValue("log", new Action<object>(Console.WriteLine))
.SetValue("assert", new Action<bool>(b => { }));

engine.Execute(@"
var startTest = function () { };
var test = function (name, fn) { fn(); };
var endTest = function () { };
var prep = function (fn) { fn(); };
");
}

[ParamsSource(nameof(FileNames))]
public string FileName { get; set; }

public IEnumerable<string> FileNames()
{
foreach (var entry in files)
{
yield return entry.Key;
}
}

[Benchmark]
public void Run()
{
engine.Execute(files[FileName]);
}
}
}
1 change: 1 addition & 0 deletions Jint.Benchmark/Jint.Benchmark.csproj
Expand Up @@ -14,6 +14,7 @@
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
</PropertyGroup>
<ItemGroup>
<None Include=".\Scripts\**" CopyToOutputDirectory="PreserveNewest" />
<None Include="..\Jint.Tests.CommonScripts\Scripts\**" CopyToOutputDirectory="PreserveNewest" LinkBase="SunSpider" />
</ItemGroup>
<ItemGroup>
Expand Down