Advertisement
WesleyJB

PassMark CPU/GPU Benchmark Script

Jul 13th, 2015
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 8.64 KB | None | 0 0
  1. @echo off
  2.  
  3. REM For those wondering, this is a very complicated script. Modify it at your own risk.
  4.  
  5. REM This pulls from PassMark's websites. All data related to your units should be there.
  6. REM If for any reason the script fails, which it will most likely close if it does, is
  7. REM because the script couldn't convert your CPU/GPU name to a valid HTML format.
  8. REM I have to remove the manufacturer name in order to make it a valid site.
  9. REM If possible, message me if it fails somehow. AMD hasn't been tested.
  10.  
  11. REM At the time of finishing this, I saw that I can add Hard Drive
  12. REM and RAM. This may be included in an extended script.
  13.  
  14. REM This took me around 8-12 hours to script and I've
  15. REM added comments to this script to explain it.
  16.  
  17. REM This script creates 12 temporary files in which to
  18. REM decode and separate data. This cannot be avoided.
  19.  
  20. REM http://imgur.com/28dfG9y
  21. REM Made by WesleyJB.
  22.  
  23.  
  24.  
  25.  
  26. REM These 2 'for' commands get the processing unit names
  27. for /F "tokens=* skip=1" %%n in ('WMIC path Win32_VideoController get Name ^| findstr "."') do set GPU_NAME=%%n
  28. echo %GPU_NAME% >gpu.adv
  29.  
  30. for /F "tokens=* skip=1" %%n in ('WMIC cpu get Name ^| findstr "."') do set CPU_NAME=%%n
  31. echo %CPU_NAME% >cpu.adv
  32.  
  33. REM Then we enable delayed expansion, which is required for the rest of the script to work right.
  34. SETLOCAL ENABLEDELAYEDEXPANSION
  35.  
  36.  
  37. REM With the first 2 commands we dumped the names to files. Now we have to remove certain things from the names.
  38. REM Since Intel is the only manufacturer of processors from what I know, we have to remove several things so we can get the data.
  39. REM It will return as "Intel(R) Series(R) Model CPU       @ x.xx GHz."
  40. REM We need this as "Intel Series Model @ x.xx GHz"
  41. REM and "Series+Model+%40+x.xx+GHz."
  42.  
  43. REM This section converts the CPU name into its HTML form.
  44.  
  45. find "@" cpu.adv > cpus.adv
  46. for %%x in (cpus.adv) do (more +2 "%%x">tmp & move /y tmp "%%x")
  47. set /p string=<cpus.adv
  48. set string=%string:(R)=%
  49. set string=%string: =+%
  50. set string=%string:"  "=%
  51. set string=%string:CPU=%
  52. set string=%string:+++=+%
  53. set string=%string:GHz+=GHz%
  54. set string=%string:++=+%
  55. set string=%string:++=+%
  56. set str1ng=%string%
  57. set replace=%%40
  58. set string=%string:@=!replace!%
  59.  
  60. set CPU=%string%
  61. echo %CPU%>cpus.adv
  62.  
  63. REM This section converts the CPU name into its written form.
  64. set str1ng=%str1ng:+= %
  65.  
  66. set CPU=%str1ng%
  67. echo %CPU%>cpu.adv
  68.  
  69.  
  70. set /p CPU=<cpus.adv
  71.  
  72.  
  73.  
  74. REM This next section codes a Visual Basic script that we need to use to access the information from the benchmark website.
  75.  
  76.  
  77. set urlben=//www.cpubenchmark.net/cpu.php?cpu=%CPU%
  78.  
  79. echo %urlben%
  80.  
  81.  
  82.  
  83.  >"%temp%\geturl.vbs" echo url      = "http:%urlben%"
  84. >>"%temp%\geturl.vbs" echo filename = "cpurating.adv"
  85. >>"%temp%\geturl.vbs" echo Set req = CreateObject("MSXML2.XMLHTTP.6.0")
  86. >>"%temp%\geturl.vbs" echo req.open "POST", url, False
  87. >>"%temp%\geturl.vbs" echo req.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
  88. >>"%temp%\geturl.vbs" echo req.send "field1=foo&field2=bar&..."
  89. >>"%temp%\geturl.vbs" echo Set fso = CreateObject("Scripting.FileSystemObject")
  90. >>"%temp%\geturl.vbs" echo fso.OpenTextFile(filename, 2, True).WriteLine req.responseText
  91.  
  92. REM Now we execute the VBScript and then delete it.
  93. cscript /nologo "%temp%\geturl.vbs"
  94. del "%temp%\geturl.vbs"
  95.  
  96.  
  97.  
  98. REM Now we get to grabbing the information from our downloaded file.
  99. REM We get the rating,
  100. for %%i in (cpurating.adv) do (
  101. FINDSTR /C:"[rating]" %%i > cpubench.adv
  102. )
  103. REM the price,
  104. for %%i in (cpurating.adv) do (
  105. FINDSTR /C:"[price]" %%i > cpuprice.adv
  106. )
  107. REM and the rank.
  108. for %%i in (cpurating.adv) do (
  109. FINDSTR /C:"[rank]" %%i > cpurank.adv
  110. )
  111.  
  112.  
  113.  
  114.  
  115. REM Now that the info is separated, we need to remove unwanted HTML code.
  116. set N=0
  117. for /f "tokens=* delims= " %%c in (cpubench.adv) do (
  118. set /a N+=1
  119. if !N! lss 3 set S=!S!%%c
  120. ) > cpubench.adv echo.!S:~12!
  121. for /f "tokens=* skip=1 delims= " %%c in (cpubench.adv) do (
  122. echo.%%c
  123. ) > cpubench.adv
  124.  
  125.  
  126. set N=0
  127. for /f "tokens=* delims= " %%c in (cpuprice.adv) do (
  128. set /a N+=1
  129. if !N! lss 3 set S=!S!%%c
  130. ) > cpuprice.adv echo.!S:~27!
  131. for /f "tokens=* skip=1 delims= " %%c in (cpuprice.adv) do (
  132. echo.%%c
  133. ) > cpuprice.adv
  134.  
  135.  
  136. set N=0
  137. for /f "tokens=* delims= " %%c in (cpurank.adv) do (
  138. set /a N+=1
  139. if !N! lss 3 set S=!S!%%c
  140. ) > cpurank.adv echo.!S:~43!
  141. for /f "tokens=* skip=1 delims= " %%c in (cpurank.adv) do (
  142. echo.%%c
  143. ) > cpurank.adv
  144.  
  145.  
  146. REM Now we repeat the same process as before for the GPU.
  147.  
  148. find "@" gpu.adv > gpus.adv
  149. for %%x in (gpus.adv) do (more +2 "%%x">tmp & move /y tmp "%%x")
  150. set /p string=<gpu.adv
  151. set string=%string:NVIDIA =%
  152. set string=%string:AMD =%
  153. set string=%string:ATI =%
  154. set string=%string:(R)=%
  155.  
  156. set replace=%%2B
  157. set string=%string:+=!replace!%
  158.  
  159. set string=%string: =+%
  160. set string=%string:+++=%
  161. set str1ng=%string%
  162. set str1ng=%str1ng:+= %
  163.  
  164.  
  165. set GPU=%string%
  166. echo %GPU%>gpus.adv
  167.  
  168. set GPU=%str1ng%
  169. echo %GPU%>gpu.adv
  170.  
  171. set /p GPU=<gpus.adv
  172.  
  173.  
  174.  
  175. REM Grab the HTML page
  176.  
  177. set urlben=//www.videocardbenchmark.net/gpu.php?gpu=%GPU%
  178.  
  179. echo %urlben%
  180.  
  181.  
  182.  
  183.  >"%temp%\geturl.vbs" echo url      = "http:%urlben%"
  184. >>"%temp%\geturl.vbs" echo filename = "gpurating.adv"
  185. >>"%temp%\geturl.vbs" echo Set req = CreateObject("MSXML2.XMLHTTP.6.0")
  186. >>"%temp%\geturl.vbs" echo req.open "POST", url, False
  187. >>"%temp%\geturl.vbs" echo req.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
  188. >>"%temp%\geturl.vbs" echo req.send "field1=foo&field2=bar&..."
  189. >>"%temp%\geturl.vbs" echo Set fso = CreateObject("Scripting.FileSystemObject")
  190. >>"%temp%\geturl.vbs" echo fso.OpenTextFile(filename, 2, True).WriteLine req.responseText
  191.  
  192.  
  193. cscript /nologo "%temp%\geturl.vbs"
  194.  
  195. del "%temp%\geturl.vbs"
  196.  
  197.  
  198. REM Grab the info
  199. REM This is different because the info isn't in a array like the CPU site.
  200. @echo on
  201.  
  202. for %%i in (gpurating.adv) do (
  203. FINDSTR /C:"font-family: Arial, Helvetica, sans-serif;font-size: 35px;  font-weight: bold; color: red;" %%i > gpubench.adv
  204. )
  205.  
  206. for %%i in (gpurating.adv) do (
  207. FINDSTR /C:"Last Price Change" %%i > gpuprice.adv
  208. )
  209.  
  210. for %%i in (gpurating.adv) do (
  211. FINDSTR /C:"Rank" %%i > gpurank.adv
  212. )
  213.  
  214.  
  215.  
  216. REM Separate the info
  217.  
  218.  
  219. set N=0
  220. for /f "tokens=* delims= " %%a in (gpubench.adv) do (
  221. set /a N+=1
  222. if !N! lss 3 set S=!S!%%a
  223. ) > gpubench.adv echo.!S:~151!
  224. for /f "tokens=* skip=1 delims= " %%a in (gpubench.adv) do (
  225. echo.%%a
  226. ) > gpubench.adv
  227.  
  228. for /f "tokens=*" %%a in (gpubench.adv) do (
  229. set xx=%%a
  230. set xx=!xx:~0,-15!
  231. echo.!xx! >gpubench.adv
  232. )
  233.  
  234.  
  235. REM Separate more info.
  236.  
  237. set N=0
  238. for /f "tokens=* delims= " %%b in (gpuprice.adv) do (
  239. set /a N+=1
  240. if !N! lss 3 set S=!S!%%b
  241. ) > gpuprice.adv echo.!S:~239!
  242. for /f "tokens=* skip=1 delims= " %%b in (gpuprice.adv) do (
  243. echo.%%b
  244. ) > gpuprice.adv
  245.  
  246. for /f "tokens=*" %%a in (gpuprice.adv) do (
  247. set xx=%%a
  248. set xx=!xx:~0,-19!
  249. echo.!xx! >gpuprice.adv
  250. )
  251.  
  252.  
  253. REM Since it's not in an array, we have to remove the code from behind the info.
  254.  
  255. set N=0
  256. for /f "tokens=* delims= " %%c in (gpurank.adv) do (
  257. set /a N+=1
  258. if !N! lss 3 set S=!S!%%c
  259. )
  260. > gpurank.adv echo.!S:~436!
  261. for /f "tokens=* skip=1 delims= " %%c in (gpurank.adv) do (
  262. echo.%%c
  263. ) > gpurank.adv
  264.  
  265. for /f "tokens=*" %%a in (gpurank.adv) do (
  266. set xx=%%a
  267. set xx=!xx:~0,-6!
  268. echo.!xx! >gpurank.adv
  269. )
  270.  
  271.  
  272. REM Now we conclude by putting all the information gathered into strings.
  273.  
  274. set /p CPU=<cpu.adv
  275. set /p CPS=<cpubench.adv
  276. set /p CPP=<cpuprice.adv
  277. set /p CPR=<cpurank.adv
  278.  
  279. set /p GPU=<gpu.adv
  280. set /p GPS=<gpubench.adv
  281. set /p GPP=<gpuprice.adv
  282. set /p GPR=<gpurank.adv
  283. @echo off
  284. rem cls
  285.  
  286.  
  287. REM Then we delete temporary data.
  288.  
  289. del "cpu.adv"
  290. del "cpus.adv"
  291. del "cpurank.adv"
  292. del "cpuprice.adv"
  293. del "cpubench.adv"
  294. del "cpurating.adv"
  295.  
  296. del "gpu.adv"
  297. del "gpus.adv"
  298. del "gpurank.adv"
  299. del "gpuprice.adv"
  300. del "gpubench.adv"
  301. del "gpurating.adv"
  302.  
  303.  
  304. REM And display the results.
  305.  
  306. mode con cols=55 lines=29
  307.  
  308. echo.
  309. echo    Here are the PassMark CPU ^& GPU Benchmark ratings
  310. echo -------------------------------------------------------
  311. echo              Central Processing Unit (CPU)
  312. echo.
  313. echo -------------------------------------------------------
  314. echo           %CPU%:
  315. echo           Rating:    %CPS%
  316. echo           Rank:      %CPR%
  317. echo           Price:     $%CPP% USD
  318. echo.
  319. echo -------------------------------------------------------
  320. echo              Graphics Processing Unit (GPU)
  321. echo.
  322. echo -------------------------------------------------------
  323. echo           %GPU%:
  324. echo           Rating:    %GPS%
  325. echo           Rank:      %GPR%
  326. echo           Price:     %GPP%
  327. echo.
  328. echo -------------------------------------------------------
  329. echo             Press any key to continue . . .
  330. echo.
  331.  
  332.  
  333.  
  334. pause >nul
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement