There is some confusion of terms. In technical terms parsing converts plain text files containing Paradox scripts into a parse tree stored in the memory of the process (this is a rather fast conversion, it probably can be done while reading the files without incurring any extra time). Compiling is an ambiguous term even within computer science. It is commonly used to indicate translation into machine instruction, but, more generally, it can mean translation into some other language. In the context of this discussion I meant compiling as compiling into machine instructions because that's what is required to have a good performance. This is a fairly expensive conversion.
Yes, it's on SSD. I don't think there is enough hardware spread to explain such difference. My guess would that it's something like active anti-virus or compression on the file system or disk driver or something like that that makes it slow for you.
To remove doubts regarding compilation I've run a small test. I've created a mod with the following event:
Code:
namespace = test
country_event = {
id = test.1
title = "test.1.name"
desc = "test.1.desc"
picture = GFX_evt_synth_organic_relations
is_triggered_only = yes
option = {
immediate = {
set_variable = {
which = total
value = 0
}
log = "test: *** Starting..."
while = {
count = 100000000
if = {
limit = {
check_variable = {
which = total
value < 1000
}
}
change_variable = {
which = total
value = 1
}
}
else = {
change_variable = {
which = total
value = 2
}
}
}
log = "test: [This.total]"
}
}
}
It takes 18-19 seconds to run when I trigger it.
The I wrote equivalent in C++
Code:
#include <iostream>
#include <cstdlib>
#include <vector>
#include <chrono>
int main(int argc, char* argv[])
{
auto start = std::chrono::high_resolution_clock::now();
int64_t count = 100000000;
volatile int64_t total = 0;
for (int64_t i = 0; i < count; ++i)
{
if (total < 1000)
total += 1;
else
total += 2;
}
auto end = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> diff = end-start;
std::cout << total << std::endl;
std::cout << "Elapsed time = " << diff.count() << "s" << std::endl;
return 0;
}
putting total into a volatile to prevent particularly aggressive optimizations. This code ran in 0.17s. So the script is about 100 times slower than the compiled code.