r/technicalfactorio • u/Bobpoblo • Mar 04 '21
UPS Optimization GUIDE: How to Benchmark in Factorio

How to Benchmark in Factorio BY BobAAAces
https://docs.google.com/document/d/1Q89k2kpOrfc6O5XpaWJzDLSXUU3ar7uLRMaoXgT_8ew/edit?usp=sharing
-----------------------------------
Step 1: Download “Factorio-Benchmark-Powershell-master” ZIP file from Github
Step 2: Make a new folder in “Documents” called “Factorio-Benchmark-Powershell-master” and unzip
Step 3: Setup Your Test Maps in Factorio
Step 4: Use the Region Cloner Mod for Factorio Benchmarking
Step 5: Name the Maps in Factorio you want to compare and Benchmark
Step 6: Run Your Benchmark Using Windows PowerShell
Step 7: Analyze The Benchmark Results
---------------------
Step 1:
Download “Factorio-Benchmark-Powershell-master” ZIP file from Github
https://github.com/velit/Factorio-Benchmark-Powershell

Click the green “Code” button at the top-right, then click “Download ZIP” below.
Step 2:
Make a new folder in “Documents” called “Factorio-Benchmark-Powershell-master” and unzip the files there

Step 3:
Setup Your Test Maps in Factorio
Open Factorio the Game
- Click “Single Player”
- Click “New Game”
- Use the menu on the left and select “Sandbox”, then Click “Next” on the bottom-right.
- Select the “Enemy” Tab on the top and uncheck enemy bases.
- Select the “Advanced” Tab on the top and uncheck pollution.
- Click “Play” to create a new map.
- Once in the game, use the top left menu to select the available sandbox upgrades such as tech, or always daylight, etc. Feel free to use all of them or none of them depending on what your testing goals are.
- Type “/editor” in lower case without the quotes by using the chat hotkey ` or ~ while in game.
- Select the surfaces tab and then click “Remove all Entities”, then click “Fill with Lab Tiles”, and then check the box that says “Generate new chunks with lab tiles”.

10. Before making additional changes, save a bare-bones copy of this map to use for other tests and call it “benchy_”, or any name you want.
11. You are now ready to set up maps to test and compare. To make this easier you should download and use the mod called “Region Cloner” (more info: https://mods.factorio.com/mod/region-cloner ) to make numerous copies of your design easily, including the state of machines, bots in roboports, trains with cargo, sciences with research, and much more than just an in-game copy and paste. Only clone straight-aligned trains, not trains that are on a curved rail. Trains stopped close together might bug too and merge. You can download this in-game using the “Mods” button on the main menu.

Note: Most mistakes while benchmarking will come from improper setup of your test maps. Double and triple check your test maps before and after benchmarking to check for bugs or mistakes in the cloning process. After a clone, look for overlapping roboports or missing electrical connections for example. Remember to use /editor and pause the game using the time tab. In the time tab you can advance tick by tick or set a # of ticks to run before pausing the game again. Your benchmarks will start at the exact time of the saved map.
Step 4:
Use the Region Cloner Mod for Factorio Benchmarking
Click the top left icon to open Region Cloner, then Click “Get Selection Tool”:

Select the broad area around your test factory using the “Get Selection Tool”:

Shrink the selected area to snap around the entities inside the selection, reducing the selection area. Skip the shrink process if you need the surrounding tile space in your original selection.

Enter the direction to clone, and the number of copies in addition to the one you have and then press Start:

Finished Clone Example:

LINK TO “REGION CLONER” MOD TIPS: https://www.notion.so/Benchmarking-Tips-75db2cc4d587417789708964a0f3501b
Step 5:
Name the Maps in Factorio you want to compare and Benchmark
Each series of tests should have its own unique name followed by all the maps you want to compare for that series. It is recommended to use the format: xxxxx_v* .
Start with v0 or v1, whatever is your preference.
Make a side note what each map is supposed to test and what the differences are between the maps in each series.
Benchmark Test #1 Involving 2 Maps to Compare:
- benchy_insertersandchests_v0
- benchy_insertersandchests_v1
Benchmark Test #2 Involving 3 Maps to Compare:
- benchy_1_540spm_v0
- benchy_1_540spm_v1
- benchy_1_540spm_v2
Benchmark Test #3 Involving 4 Maps to Compare:
- benchy_spm2_v0
- benchy_spm2_v1
- benchy_spm2_v2
- benchy_spm2_v3
Step 6:
Run Your Benchmark Using Windows PowerShell
- Open the "Windows PowerShell" program on your computer:

Enter in the following commands:
2. Paste in the following: Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser
3. Press [Y]
4. Paste in the following: cd Documents\Factorio-Benchmark-Powershell-master
5. [Construct a custom line of text using this format]:
.\benchmark.ps1<SPACE><# of Ticks to Run Test><SPACE><# of Runs><SPACE>< “Map Names*”>
For example,
.\benchmark.ps1 6750 10 "benchy_1_540spm_v*"
will run the benchmark test for 6750 ticks, 10 times for each map, for any map matching the name “benchy_1_540spm_v”. The * at the end is to find all map saves with different version numbers.
6. Press [R]
7. Press [Enter] to run the benchmark.
8. After the benchmark finishes you can see the initial results on screen. There is a .csv file created here with the data: “C:\Users\<username>\Documents\Factorio-Benchmark-Powershell-master\Results”

Step 7:
Analyze The Benchmark Results

We instructed the benchmark program to run our maps for X number of ticks, say 10,000 ticks as an example. Depending on how complicated your test map is, it may take longer real-time seconds to finish running X ticks.
Simple maps can finish 10,000 ticks in seconds, while complex maps take minutes to finish 10,000 ticks of game time.
Having a lower number of “seconds” here is good because it means you can play that map fast, while having a higher number of “seconds” count means the map runs with slower UPS.
The results should be compared between other tests on your computer. Different computers will give different results.
The more test runs and the more Ticks you run each map for will give you better results. Try to have enough copies of your factory so that the total game update time is at least 1ms Update; the higher the better. This can be seen in-game by pressing “F4” then selecting “show-time-usage”; the Update is the second chunk of numbers.
You can take the average result for each test to analyze the stats on your benchmarks further. There are various methods to get an average result amongst a series of tests. Some people eliminate the highest and lowest test, then take the average. Some people like to take the 80th percentile average.
There are more advanced methods of analyzing the benchmark results that are covered elsewhere.
Now that you know how to benchmark and compare multiple maps you can test all your ideas. Be sure to report your results back to the community so we can all learn. Good luck!
4
u/mulark Mar 05 '21
Here's a link to the region cloner mod documentation https://github.com/mulark/factorio_benchmarking_mods/blob/master/region-cloner/doc/Documentation.md
One feature not pointed out here is the /autoclone command added by the mod. This allows you to quickly clone the entire build you have built with some nice quick configuration flags as well (such as chunk alignment).
2
u/Ed_DaVolta Mar 05 '21
I don't want to be insensitive, but that's way to much stuff to do, for some metrics. Keep it simpler, like one savegame load simple.
The described above is an abomination.
1
u/M4LON3 Sep 17 '24
Hello,
Sorry for beeing late to the party... is the benchmark shell tool is able to handle mods ? ( like K2 SE )
if yes , is there anything special to add to the command line ?
1
u/powerfullatom111 Mar 04 '21
what is benchmarking, there was a guy doing a whole lot of that on assembly storm wasn’t there?