-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'devel' into issues/#125-overflow-2
- Loading branch information
Showing
243 changed files
with
15,984 additions
and
16,107 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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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 |
---|---|---|
@@ -1,45 +1,44 @@ | ||
namespace Mages.Core.Performance | ||
namespace Mages.Core.Performance; | ||
|
||
using BenchmarkDotNet.Attributes; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
public class CachedBenchmarks | ||
{ | ||
using BenchmarkDotNet.Attributes; | ||
using System; | ||
using System.Collections.Generic; | ||
private static readonly String CallStandardFunctions = "sin(pi / 4) * cos(pi * 0.25) + exp(2) * log(3)"; | ||
private static readonly Engine MagesEngine = new(); | ||
private static readonly Dictionary<String, Func<Object>> FunctionCache = []; | ||
|
||
public class CachedBenchmarks | ||
[Benchmark] | ||
public Double Mages_Uncached_CallStandardFunctions() | ||
{ | ||
private static readonly String CallStandardFunctions = "sin(pi / 4) * cos(pi * 0.25) + exp(2) * log(3)"; | ||
private static readonly Engine MagesEngine = new Engine(); | ||
private static readonly Dictionary<String, Func<Object>> FunctionCache = new Dictionary<String, Func<Object>>(); | ||
|
||
[Benchmark] | ||
public Double Mages_Uncached_CallStandardFunctions() | ||
{ | ||
return MagesUncachedNumeric(CallStandardFunctions); | ||
} | ||
return MagesUncachedNumeric(CallStandardFunctions); | ||
} | ||
|
||
[Benchmark] | ||
public Double Mages_Cached_CallStandardFunctions() | ||
{ | ||
return MagesCachedNumeric(CallStandardFunctions); | ||
} | ||
[Benchmark] | ||
public Double Mages_Cached_CallStandardFunctions() | ||
{ | ||
return MagesCachedNumeric(CallStandardFunctions); | ||
} | ||
|
||
private Double MagesCachedNumeric(String sourceCode) | ||
private Double MagesCachedNumeric(String sourceCode) | ||
{ | ||
var func = default(Func<Object>); | ||
|
||
if (!FunctionCache.TryGetValue(sourceCode, out func)) | ||
{ | ||
var func = default(Func<Object>); | ||
|
||
if (!FunctionCache.TryGetValue(sourceCode, out func)) | ||
{ | ||
func = MagesEngine.Compile(sourceCode); | ||
FunctionCache[sourceCode] = func; | ||
} | ||
|
||
var result = func.Invoke(); | ||
return (Double)result; | ||
func = MagesEngine.Compile(sourceCode); | ||
FunctionCache[sourceCode] = func; | ||
} | ||
|
||
var result = func.Invoke(); | ||
return (Double)result; | ||
} | ||
|
||
private Double MagesUncachedNumeric(String sourceCode) | ||
{ | ||
var result = MagesEngine.Interpret(sourceCode); | ||
return (Double)result; | ||
} | ||
private Double MagesUncachedNumeric(String sourceCode) | ||
{ | ||
var result = MagesEngine.Interpret(sourceCode); | ||
return (Double)result; | ||
} | ||
} |
Oops, something went wrong.