It's nearly impossible to answer without a model. But here are my thoughts on what you have provided.
My biggest concern is in comparing two different models. When converting activities to code (or vice-versa), it can actually be difficult to perform the exact same steps. For example, I see many Assign Labels activities. Often, when converting to code, people will not assign values to labels, and instead just use local variables. Usually, that means a speed improvement. But sometimes, using labels forces you to cache certain values earlier, and then look them up, where the code version may do a search every time. In that case, your code version would be a little slower.
So here's how I see it. If you convert from many activities to a single code block, you may see a little improvement. Usually, it's not worth your time; Process Flow adds very little overhead. In most cases, it's the approach that is either fast or slow, whether a token is moving through activities, or whether the code is executing directly. For example, if you search through a table, or use a WHERE query on a list, that is slower than looking up table rows with an index, or pulling from a partition without a WHERE clause. The choices of algorithm and data structure will dictate 99% or more of your performance.
So I can't explain why your two models perform differently. That would require you to provide both models, and for someone on the forum to do a deep analysis, to find the difference in algorithm between the two approaches. It could come down to the way you used certain commands, or shifting one line of code out of a for loop, or using a label instead of a local variable. But hopefully, you can analyze your own code and find opportunities for a speed-up.
I see the word "Dijkstra" in your comment. We recently made our AStar module public, so you can view the code. You may find it interesting:
https://github.com/flexsim/AStar
(Note: the github website was down when I wrote this, so you'll have to wait for it to be back up)