1;
2; AC, July 2017, GPL V3+
3;
4; Collecting informations on the CPU
5; -- processor name
6; -- cores number  <<-- tricks on OSX due to OpenMP
7; -- bogomips   <<-- does not exist on OSX
8; -- cpu MHz
9;
10function BENCHMARK_GENERATE_CPUINFO, test=test, verbose=verbose, help=help
11;
12if KEYWORD_SET(help) then begin
13   print, 'function BENCHMARK_GENERATE_CPUINFO, test=test, verbose=verbose, help=help'
14   return, -1
15endif
16;
17os_name=STRLOWCASE(!version.os)
18;
19if (os_name EQ 'linux') then begin
20   ;;
21   SPAWN, 'more /proc/cpuinfo  | grep MHz', resu_Mhz
22   resu_mhz=STRMID(resu_Mhz[0], STRPOS(resu_Mhz[0],':')+2)
23   resu_mhz=FLOAT(resu_mhz)
24   ;;
25   SPAWN, 'more /proc/cpuinfo  | grep bogo', resu_bogo
26   resu_bogo=STRMID(resu_bogo[0], STRPOS(resu_bogo[0],':')+2)
27   resu_bogo=FLOAT(resu_bogo)
28   ;;
29   SPAWN, 'more /proc/cpuinfo  | grep "model name"', model_name
30   model_name=STRMID(model_name[0], STRPOS(model_name[0],':')+2)
31   ;;
32endif
33;
34if (os_name EQ 'darwin') then begin
35   ;;
36   SPAWN, 'sysctl -n hw.cpufrequency', resu_Hz
37   resu_Mhz=resu_Hz/1.e6
38   ;;
39   ;; no known equivalent of BogoMIPS on OSX :(
40   resu_bogo=-1
41   ;;
42   SPAWN, 'sysctl -n machdep.cpu.brand_string', model_name
43   ;;
44endif
45;
46if (os_name EQ 'windows') then begin
47   ;;
48   SPAWN, 'wmic cpu get maxclockspeed', resu_Mhz
49   resu_Mhz=FLOAT(resu_Mhz[1])
50   ;;
51   ;; no known equivalent of BogoMIPS on MSWin eiter :(
52   resu_bogo=-1
53   ;;
54   SPAWN, 'wmic cpu get name', model_name
55   model_name=model_name[1]
56   ;;
57endif
58;
59cpu_info={MHz : resu_Mhz, $
60          Bogo : resu_bogo, $
61          model : model_name, $
62          used_cores : !cpu.TPOOL_NTHREADS, $
63          nb_cores : !cpu.HW_NCPU} ; not fully clear ...
64;
65if KEYWORD_SET(verbose) then HELP,/struct, cpu_info
66if KEYWORD_SET(test) then STOP
67;
68return, cpu_info
69;
70end
71;
72