Re: Performance test agains Python

2020-03-07 Thread cumulonimbus
You are also testing cache effect times at least as much as you are testing the code you are running; Either take minimum-of-5 sequential runs, or an average of 10 loops or so (or both); Not sure about Win10, but for sure Windows used to report times in multiples of ~16ms at least as late as

Re: Performance test agains Python

2020-03-06 Thread mratsim
I'm always saying that but `strutils` is the biggest performance trap of Nim. The operations always return a new string which makes it easy to compose and very very heavy on the memory management. Python and Javascript have heavy optimizations done from string and fast string manipulation in

Re: Performance test agains Python

2020-03-06 Thread Stefan_Salewski
> Ok, I guess the string manipulations in Python are implemented with C as well, Yes, most basic operations in Python are generally coded in C and are optimized well. But what you can try: Put all your code in a main() proc. Whenever you do benchmarking, you should do that, in some cases it

Re: Performance test agains Python

2020-03-06 Thread NimFI
Ok, I guess the string manipulations in Python are implemented with C as well, and there is not much of lack from dynamic nature of Python in this case. I checked once more after all the modifications to both codes, with 100% same replaced lines, here's the results: Nim: 0.085 s Python: 70.0

Re: Performance test agains Python

2020-03-06 Thread Vindaar
As far as I know such simple string manipulations are actually pretty fast in python. So don't expect an amazing speed improvement over python if your code is this simple. In more "real world" examples you'll see Nim outperforming Python.

Re: Performance test agains Python

2020-03-06 Thread NimFI
still at 0.09 s with: var flDurat: float = 0.0 sFind: string = seqParams[1].replace("\"", "") sLine: string = "" let sFile: string = seqParams[0] sReplaced: string = seqParams[2].replace("\"", "") flTime= cpuTime()

Re: Performance test agains Python

2020-03-06 Thread NimFI
Thanks, I actually removed the unnecessary find already, but I didn't notice I do the replace for the sReplaced variable every time, which is silly. Will test again!

Re: Performance test agains Python

2020-03-06 Thread Vindaar
You have to be aware that using strings this way is always going to be somewhat inefficient, since each replace call will make a copy! Of those especially in the following: f2.writeLine(sLine.replace(sFind, sReplaced.replace("\"", ""))) Run the sReplaced.replace("",

Re: Performance test agains Python

2020-03-06 Thread NimFI
Oh! Sorry, I added the -d:release, but when compiling with _only_ that flag, I got: 0.085 s So pretty much as fast as python, although I assumed would be still faster?

Re: Performance test agains Python

2020-03-06 Thread NimFI
Now it's around 0.2 seconds with the -d:release

Re: Performance test agains Python

2020-03-06 Thread miran
> `#Compile: nim --passc:-flto --opt:size c test.nim` Use `-d:release` and try again, please.

Performance test agains Python

2020-03-06 Thread NimFI
Hello Nim users! Just discovered Nim and have been playing with it. Can you tell me what I am doing wrong here? Because Python seems to be much _faster_ than Nim with this code? This python code is executed to a text file with 3.6MB in size, some 43000 lines. (sorry, can not publish the file)