Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / String Functions slowing program

Years of Service
User Offline
Joined: 1st Jun 2012
Posted: 2nd Jun 2012 04:01
Hi all,

First time poster, but I have used DBPro on and off since it was first released, so not exactly a "noob".

Anyway, this is a bizarre one - to me at least. I have dug out an old project. It's a simple program I have used for years as a benchmark - a loop that finds the first x number of prime numbers. It is currently set to find the first 10,000, and prints to the screen every 1000 numbers, with the elapsed time.

As part of a wider project, I wanted to add some command line switches to alter the parameters. Simple stuff, but whatever I use to split the command line string up - first/next token$, find first char$, even mid$ - it slows the program up dramatically. Normally, it should take under 4 seconds to cycle through the first 10,000 primes, but as soon as you add any of those commands, it takes about 3 minutes.

It doesn't make sense. This code is obviously at the beginning of the program, and separate from the actual "number crunching" code. Just to help track down the problem, I commented out all the related code, and introduced single lines from it, and confirmed that it is the string manipulation that causes the problem.

Any thoughts ? I did wonder if it was related to the fact that I am using an HP Netbook, with "pseudo" or Virtual dual-core processor. In other words one that has one core, but two threads ?
Years of Service
User Offline
Joined: 23rd Jul 2006
Posted: 2nd Jun 2012 20:19

even though this is the DBC board, the methods should be the same.
The string functions are a bit slow, but the speed you describe seems like somethings wrong. Maybe there's a problem with how you built your string parser?

Anyway, here's an example of a method that accompllishes what you seem to describe. This runs from the command line 5 seconds on my old single core 1.5ghz machine (using DBC) - when testing for 10000 primes starting at 0.

Enjoy your day.

Login to post a reply

Server time is: 2020-08-05 09:45:15
Your offset time is: 2020-08-05 09:45:15