in reply to it takes 1-2 seconds to return a string from a subrountine
Another wild guess... Could it be that your counter is local to the subroutine, and outside it you see a totally other (perhaps uninitialized) counter ?
Also, try to run this function only, if it's 1-2 secs indeed you'll feel it. If it's instant (the way it should be on any normal machine), the problem is with your counter.