-
-
Notifications
You must be signed in to change notification settings - Fork 547
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Function call performance improvements (#703)
* use adapting HybridDictionary for DeclarativeEnvironmentRecord * lazily materialize arguments when needed * return ArgumentsInstance to pool when we can * return compatibility with RavenDB usage * remove function callback logic from DeclarativeEnvironmentRecord
- Loading branch information
Showing
25 changed files
with
629 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
using System.Collections.Generic; | ||
using Jint.Collections; | ||
using BenchmarkDotNet.Attributes; | ||
|
||
namespace Jint.Benchmark | ||
{ | ||
[MemoryDiagnoser] | ||
public class DictionaryBenchmark | ||
{ | ||
private static readonly string[] _keys = | ||
{ | ||
"some", | ||
"key and", | ||
"another", | ||
"varying", | ||
"---the --", | ||
"keys and more", | ||
"aa bbb", | ||
"asasd asd ", | ||
"asdsad asd as s", | ||
"asdadsasa", | ||
"23323232323", | ||
"asdadsada sa213" | ||
}; | ||
|
||
[Params(0, 2, 3, 5, 8, 9, 10)] | ||
public int N { get; set; } | ||
|
||
[Benchmark] | ||
public void HybridDictionary() | ||
{ | ||
var hybridDictionary = new HybridDictionary<string, object>(); | ||
for (var i = 0; i < N; i++) | ||
{ | ||
hybridDictionary.Add(_keys[i], _keys); | ||
} | ||
|
||
foreach (var key in _keys) | ||
{ | ||
hybridDictionary.ContainsKey(key); | ||
} | ||
} | ||
|
||
[Benchmark] | ||
public void Dictionary() | ||
{ | ||
var dictionary = new Dictionary<string, object>(); | ||
for (var i = 0; i < N; i++) | ||
{ | ||
dictionary.Add(_keys[i], _keys); | ||
} | ||
|
||
foreach (var key in _keys) | ||
{ | ||
dictionary.ContainsKey(key); | ||
} | ||
} | ||
|
||
[Benchmark] | ||
public void StringDictionarySlim() | ||
{ | ||
var dictionary = new StringDictionarySlim<object>(); | ||
for (var i = 0; i < N; i++) | ||
{ | ||
dictionary[_keys[i]] =_keys; | ||
} | ||
|
||
foreach (var key in _keys) | ||
{ | ||
dictionary.ContainsKey(key); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
using System.Runtime.CompilerServices; | ||
|
||
[assembly: InternalsVisibleTo("Jint.Benchmark, PublicKey=0024000004800000940000000602000000240000525341310004000001000100bf2553c9f214cb21f1f64ed62cadad8fe4f2fa11322a5dfa1d650743145c6085aba05b145b29867af656e0bb9bfd32f5d0deb1668263a38233e7e8e5bad1a3c6edd3f2ec6c512668b4aa797283101444628650949641b4f7cb16707efba542bb754afe87ce956f3a5d43f450d14364eb9571cbf213d1061852fb9dd47a6c05c4")] |
Oops, something went wrong.