New topic: About instr() performances
<http://forums.realsoftware.com/viewtopic.php?t=47007> Page 1 of 1 [ 1 post ] Previous topic | Next topic Author Message Sergio Tallone Post subject: About instr() performancesPosted: Wed Feb 20, 2013 11:38 am Joined: Wed Jan 19, 2011 2:52 am Posts: 8 Good morning,if possible I need a clarification related to a feature of Realstudio. While I was testing an old code written for another compiler, I realized that the function instr () is extremely slow. The sample program below, loads a text file (about 50000 lines) into a string and then counts the occurrences of a given string. On my PC (Windows 7 Pro 64-bit - i5-3450 3.10 GHz and 16 GB of RAM), the program takes about 16 seconds for the count, value fairly high compared for example with the one obtained by the same code with FreeBASIC (0.02 seconds). I'm not interested in an algorithm that can improve the speed of the count but I would like to know if these poor results are related to my lack of knowledge of the various aspects of Realstudio. #pragma DisableBackgroundTasks dim f As FolderItem dim t as TextInputStream dim count as integer dim length As integer dim point, found As integer dim start,stop as double dim temp As string f = GetFolderItem("test.txt") if f.Exists then t = TextInputStream.Open(f) if t <> nil then temp = t.ReadAll() length = len(temp) t.Close point = 1 start = microseconds/1000000 do found = instr(point,temp, "TRGL") if found = 0 then exit do count = count + 1 point = found + 1 loop stop = microseconds/1000000 msgbox str(count) + " items found" + EndOfLine + _ "Elapsed time: " + str(stop - start) + " seconds" end if end if If anyone would like to check my results this is the link of the file used for the test with the version of Real Studio 2012-2.1. https://dl.dropbox.com/u/79819428/test.zip Any suggestions? thanks Sergio Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 1 post ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
