yum-archive/TaSTT-Whisper

High-performance GPGPU inference of OpenAI's Whisper automatic speech recognition (ASR) model

git clone https://git.yummers.dev/yum-archive/TaSTT-Whisper

KonstantinMinor, performance summary toole8ff6c5

master
2.0 KiB88 linesraw
1using System.Globalization;
2
3namespace PerfSummary
4{
5	static class Summary
6	{
7		public static void print( LogData[] logs, string folder )
8		{
9			string path = Path.Combine( folder, "summary.tsv" );
10			using var writer = File.CreateText( path );
11
12			string[] header = new string[]
13			{
14				"Audio Clip", "Model", "GPU",
15				"Total, sec", "Relative speed",
16				"Encode, sec", "Decode, sec",
17				"RAM, MB", "VRAM, MB"
18			};
19			writer.fields( header );
20
21			foreach( var item in logs )
22				writer.fields( item.makeFields() );
23		}
24
25		static IEnumerable<string> makeFields( this LogData log )
26		{
27			yield return log.clip();
28			yield return log.name.model.ToString();
29			yield return log.gpu();
30			yield return log.runComplete.print();
31			yield return log.relative();
32			yield return log.encode.print();
33			yield return log.decode.print();
34			yield return log.ram.print();
35			yield return log.vram.print();
36		}
37
38		static string print( this double v ) =>
39			v.ToString( CultureInfo.InvariantCulture );
40
41		static string relative( this LogData log )
42		{
43			double duration;
44			switch( log.name.clip )
45			{
46				case eInputClip.jfk:
47					duration = 11;
48					break;
49				case eInputClip.columbia:
50					duration = TimeSpan.FromTicks( 1987620000 ).TotalSeconds;
51					break;
52				default:
53					throw new NotImplementedException();
54			}
55
56			double rel = duration / log.runComplete;
57			return rel.ToString( "F4", CultureInfo.InvariantCulture );
58		}
59
60		static string clip( this LogData log )
61		{
62			return log.name.clip switch
63			{
64				eInputClip.jfk => "jfk.wav",
65				eInputClip.columbia => "columbia.wma",
66				 _ => throw new ArgumentException()
67			};
68		}
69
70		static string gpu( this LogData log )
71		{
72			return log.name.gpu switch
73			{
74				"1080ti" => "GeForce 1080Ti",
75				"1650" => "GeForce 1650",
76				"vega7" => "Ryzen 5 5600U",
77				"vega8" => "Ryzen 7 5700G",
78				_ => log.name.gpu
79			};
80		}
81
82		static void fields( this StreamWriter writer, IEnumerable<string> fields )
83		{
84			string line = string.Join( "\t", fields );
85			writer.WriteLine( line );
86		}
87	}
88}