1
+ # Helper script to run the bench tool on all models and print the results in share-able format
2
+
3
+ Write-Host " Usage: .\bench-all.ps1 [n_threads]`n "
4
+
5
+ if ($args.Length -eq 0 ) {
6
+ $n_threads = 4
7
+ } else {
8
+ $n_threads = $args [0 ]
9
+ }
10
+
11
+ $models = @ ( " tiny" , " base" , " small" , " medium" , " large" )
12
+
13
+ Write-Host " `n Running memcpy benchmark with 1 thread`n "
14
+
15
+ .\bench - w 1 - t 1
16
+
17
+ Write-Host " `n Running ggml_mul_mat benchmark with $n_threads threads`n "
18
+
19
+ .\bench - w 2 - t $n_threads
20
+
21
+ Write-Host " `n Running benchmark for all models"
22
+ Write-Host " This can take a while!`n "
23
+
24
+ Write-Host " | CPU | OS | Config | Model | Th | Load | Enc. | Commit |"
25
+ Write-Host " | --- | -- | ------ | ----- | -- | ---- | ---- | ------ |"
26
+
27
+ $commit = git rev- parse -- short HEAD
28
+ $cpu_name = (Get-CimInstance - ClassName Win32_Processor).Name
29
+ $os = ((Get-WMIObject win32_operatingsystem).name).split(" |" )[0 ]
30
+
31
+ foreach ($model in $models ) {
32
+ # run once to heat-up the cache
33
+ .\bench - m .\models\ggml- $model.bin - t $n_threads 2>&1 | Out-Null
34
+
35
+ # actual run
36
+ # store stderr output in a variable in order to parse it later
37
+ $output = .\bench - m .\models\ggml- $model.bin - t $n_threads 2>&1
38
+
39
+ # parse the output:
40
+ $load_time = (($output | Select-String " load time" ) -split " [\s]+" )[4 ]
41
+ $encode_time = (($output | Select-String " encode time" ) -split " [\s]+" )[4 ]
42
+ $system_info = ($output | Select-String " system_info" ).ToString()
43
+ $n_threads = ($system_info -split " [\s]+" )[3 ]
44
+
45
+ # convert the time values to float type
46
+ $load_time = [float ]::Parse($load_time )
47
+ $encode_time = [float ]::Parse($encode_time )
48
+
49
+ # floor to milliseconds
50
+ $load_time = [math ]::Floor($load_time )
51
+ $encode_time = [math ]::Floor($encode_time )
52
+
53
+ $config = " "
54
+
55
+ if ($system_info.Contains (" AVX2 = 1" )) {
56
+ $config += " AVX2"
57
+ }
58
+
59
+ if ($system_info.Contains (" NEON = 1" )) {
60
+ $config += " NEON"
61
+ }
62
+
63
+ if ($system_info.Contains (" BLAS = 1" )) {
64
+ $config += " BLAS"
65
+ }
66
+
67
+ Write-Host " | $cpu_name | $os |$config | $model | $n_threads | $load_time | $encode_time | $commit |"
68
+ }
0 commit comments