public static List <CompileTimeInfo> ParseFromJsonString(ref string json) { var root = JObject.Parse(json); return(root["traceEvents"].Select(m => { var timeInfo = new CompileTimeInfo() { processId = m.Value <int>("pid"), threadId = m.Value <int>("tid"), phase = m.Value <string>("ph"), beginMilliSeconds = m.Value <long>("ts"), durationMilliSeconds = m.Value <long>("dur"), compileGroupName = m.Value <string>("name") }; // optional args timeInfo.name = m .SelectToken("args.detail") ?.Value <string>() .Replace("\\", "/"); // TODO add more optional args ... return timeInfo; }).ToList()); }
static void Main(string[] args) { var directory = Path.Combine(Environment.CurrentDirectory, args.Last()); if (!Directory.Exists(directory)) { return; } var files = Directory.EnumerateFiles(directory, "*", SearchOption.AllDirectories) .GroupBy(m => { var d = Path.GetExtension(m); var f = m.Replace(d, ""); return(f); }) .Where(m => m.Count() >= 2 && m.Any(n => Path.GetExtension(n) == ".json")) .Select(m => m.Where(n => Path.GetExtension(n) == ".json").First()) .AsParallel() .Select(m => { using (StreamReader reader = new StreamReader(m)) { var json = reader.ReadToEnd(); var infos = CompileTimeInfo.ParseFromJsonString(ref json); var profile = new CompileTimeInfoContainer() { fileName = m, infos = infos }; return(profile); } }) .OrderBy(m => m.fileName) .ToList(); Analyze(files); }