Guest User

Untitled

a guest
Oct 26th, 2017
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #run every map in the saves directory?
  2. [bool]$allmaps = 1
  3.  
  4. if ($allmaps)
  5.     {
  6.     $maps = dir ..\..\saves -n
  7.     }
  8.     else
  9.     {
  10.     [string[]]$maps = "List_the_names.zip With_a_space.zip You_dont_need_the" #.zip
  11.     $maps = $maps -split " "
  12. }
  13. #Number of seconds of simulation (higher = less error)
  14. $seconds = 600
  15.  
  16. #Number of runs per map
  17. $runs = 5
  18.  
  19. #End of user variables
  20.  
  21. #Put the name of every map in the result file
  22. $maps -join "," >> test_results.csv
  23. #Cut function because muh linux
  24. function cut {
  25.   param(
  26.     [Parameter(ValueFromPipeline=$True)] [string]$inputobject,
  27.     [string]$delimiter='\s+',
  28.     [string[]]$field
  29.   )
  30.   process {
  31.     if ($field -eq $null) { $inputobject -split $delimiter } else {
  32.       ($inputobject -split $delimiter)[$field] }
  33.   }
  34. }
  35.  
  36. #run index
  37. $i = 0
  38. #map index
  39. $k = 0
  40.  
  41. $ticks = $seconds * 60
  42. while ($i -lt $runs){
  43.    
  44.     for ($k = 0; $k -lt $maps.length; $k++)
  45.     {
  46.         #Load the factorio executable with the settings above in benchmark mode
  47.         #Piping to out-null ensures that the process completes before the next command is executed
  48.         .\factorio.exe --benchmark $maps[$k] --benchmark-ticks $ticks --disable-audio | out-null
  49.        
  50.         #Make a copy of the log in our current directory, keep the original intact
  51.         copy ..\..\factorio-current.log .
  52.        
  53.         #select the first field from the last two lines (the time of the last two events)
  54.         $array = cat .\factorio-current.log | cut -f 1 | Select-Object -last 2
  55.        
  56.         #Fill the index of the current map with the calculated milliseconds
  57.         [string[]]$ms += [math]::Round(($array[1] - $array[0]) / ($ticks / 1000),3)
  58.     }
  59.     #Record the milliseconds from all maps this run
  60.     $ms -join"," >> test_results.csv
  61.    
  62.     #clear the variable before the next pass
  63.     clear-variable ms
  64.     $i++;
  65.     echo "run# $i finished"
  66.  
  67. }
Add Comment
Please, Sign In to add comment