Skip to content

Commit

Permalink
[jit-times] add method name sorting, more switches (#7129)
Browse files Browse the repository at this point in the history
We needed to sort methods by name to compare JIT times for .NET 6 vs .NET 7.

I added a feature for this and the long-form of switches.

Help output is now:

	> jit-times --help
	Usage: jit-times.exe OPTIONS* <methods-file>
	
	Processes JIT methods file from XA app with debug.mono.log=timing enabled
	
	Copyright 2019 Microsoft Corporation
	
	Options:
	-h, --help, -?             Show this message and exit
	-m, --method=TYPE-REGEX    Process only methods whose names match TYPE-REGEX.
	-s, --sort-self-times      Sort by self times. (this is default ordering)
	-t, --sort-total-times     Sort by total times.
	-n, --sort-methods         Sort by method names.
	-u, --unsorted             Show unsorted results.
	-v, --verbose              Output information about progress during the run
	                            of the tool
  • Loading branch information
jonathanpeppers committed Jun 28, 2022
1 parent 54f15d7 commit aa4315b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions tools/jit-times/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ enum SortKind {
Unsorted,
Self,
Total,
Method,
};

static SortKind sortKind = SortKind.Self;
Expand All @@ -38,13 +39,16 @@ static string ProcessArguments (string [] args)
{ "m|method=",
"Process only methods whose names match {TYPE-REGEX}.",
v => methodNameRegexes.Add (new Regex (v)) },
{ "s",
{ "s|sort-self-times",
"Sort by self times. (this is default ordering)",
v => sortKind = SortKind.Self },
{ "t",
{ "t|sort-total-times",
"Sort by total times.",
v => sortKind = SortKind.Total },
{ "u",
{ "n|sort-methods",
"Sort by method names.",
v => sortKind = SortKind.Method },
{ "u|unsorted",
"Show unsorted results.",
v => sortKind = SortKind.Unsorted },
{ "v|verbose",
Expand Down Expand Up @@ -211,6 +215,9 @@ static Timestamp PrintSortedMethods ()
case SortKind.Total:
enumerable = methods.OrderByDescending (p => p.Value.total);
break;
case SortKind.Method:
enumerable = methods.OrderByDescending (p => p.Value.method);
break;
default:
throw new InvalidOperationException ("unknown sort order");
}
Expand Down

0 comments on commit aa4315b

Please sign in to comment.