Skip to content

Instantly share code, notes, and snippets.

@mattpodwysocki
Last active August 29, 2016 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattpodwysocki/a857715827975ab022b905952f686d31 to your computer and use it in GitHub Desktop.
Save mattpodwysocki/a857715827975ab022b905952f686d31 to your computer and use it in GitHub Desktop.
C# P/Invoke ChakraJavaScript Executor:
Before Invoking:
App Report: private commit usage: 62676992, peak private commit usage: 62676992, total commit usage: 141225984
Process Report: private working set: 35823616, total working set: 82153472
Ticks Elapsed: 351260
After Invoking:
App Report: private commit usage: 85008384, peak private commit usage: 85118976, total commit usage: 163557376
Process Report: private working set: 55824384, total working set: 102326272
C#/C++ NativeJavaScriptExecutor:
Before Invoking:
App Report: private commit usage: 56909824, peak private commit usage: 56909824, total commit usage: 134606848
Process Report: private working set: 30326784, total working set: 67002368
Ticks Elapsed: 292577
After Invoking:
App Report: private commit usage: 73699328, peak private commit usage: 78311424, total commit usage: 151396352
Process Report: private working set: 44838912, total working set: 81633280
Performance Increases:
Before Invoking:
App Report: private commit usage: 9% decrease, peak private commit usage: 9% decrease, total commit usage: 4% decrease
Process Report: private working set: 15% decrease, total working set: 18% decrease
Ticks Elapsed: 16% increase
After Invoking:
App Report: private commit usage: 13% decrease, peak private commit usage: 7% decrease, total commit usage: 4% decrease
Process Report: private working set: 20% decrease, total working set: 20% decrease
using System.Diagnostics;
using Windows.System;
namespace ReactNative.Chakra.Executor
{
static class ChakraMemoryUsage
{
public static void PrintMemoryReport()
{
var appReport = MemoryManager.GetAppMemoryReport();
Debug.WriteLine($"App Report: private: {appReport.PrivateCommitUsage}, peak private: {appReport.PeakPrivateCommitUsage}, total commit: {appReport.TotalCommitUsage}");
var procReport = MemoryManager.GetProcessMemoryReport();
Debug.WriteLine($"App Report: private working set: {procReport.PrivateWorkingSetUsage}, total working set: {procReport.TotalWorkingSetUsage}");
}
public static Stopwatch GetStopwatch()
{
var watch = new Stopwatch();
watch.Start();
return watch;
}
public static void PrintResults(Stopwatch stopwatch)
{
stopwatch.Stop();
Debug.WriteLine($"Elapsed: {stopwatch.ElapsedTicks}");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment