Skip to content

Commit

Permalink
Use pre-allocated stringbuilder to reduce string concatenation cost
Browse files Browse the repository at this point in the history
  • Loading branch information
Amiya Gupta committed Mar 29, 2018
1 parent 082f17a commit 05b58bb
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Program.cs
Expand Up @@ -55,20 +55,20 @@ class Program
{ "Wininet_LookupConnection/Stop", 1048 },
{ "WININET_STREAM_DATA_INDICATED", 1064 }
};

static TraceEventSession session;
static bool must_exit = false;
private static Mutex mutex = new Mutex();
private static Mutex mutex = new Mutex();
static StringBuilder events = new StringBuilder(2000000);
static string body_dir = "";
static Dictionary<string, CustomProvider> customProviders = new Dictionary<string, CustomProvider>();
static string customProvidersConfigPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @".\customProviders.json");
static string customProvidersConfigPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @".\customProviders.json");

static void Main(string[] args)
{
if (args.Length == 2 && args[0] == "--bodies" && System.IO.Directory.Exists(args[1]))
body_dir = args[1];

// read settings for custom ETW providers
if (File.Exists(customProvidersConfigPath))
{
Expand Down Expand Up @@ -234,13 +234,13 @@ private static void ThreadProc()
mutex.WaitOne();
if (events.Length > 0)
{
buff = events.ToString();
buff = events.ToString();
events.Clear();
}
mutex.ReleaseMutex();

if (buff.Length > 0)
{
{
content = new StringContent(buff, Encoding.UTF8, "application/json");
try
{
Expand Down

0 comments on commit 05b58bb

Please sign in to comment.