Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - davidf

Pages: [1]
1
QB64 Discussion / QB64 File I/O speeds compared to QB are really slow
« on: March 17, 2020, 12:29:32 pm »
Apologies i must have pressed post halfway through typing

I have just been testing some programs that were originally written in VBDOS (Never used the GUI stuff)

I got the programs running without problems except that the speed was much slower.

One section that very marked difference was taking about 4 seconds (VBDOS) and in QB64 over 65 seconds.

After further investigation it was apparent that the time differences were taking place during file i/o.

The programs are used for nesting different components on sheets, and then generating the Laser CNC cutting programs.
It is during the generation of these CNC programs , there is a lot of file i/o reading and writing of text files.

I then wrote a small program to see the differences between QB, VBDOS and QB64 , the results are significant.
The program creates 100,000 LINES OF CSV data ( 5 data items , ie 4 commas), using the Print #, Write #, functions

The program then reads back the data
Using Input #, and then Line Input # functions
In the QB64 test , i have used the Line input # (Binary mode) it is not available in QB and VBDOS

The times shown are in seconds

Task                  QB          VBDOS        QB64         VB5
Print #              1.76         1.76         12.14        0.89
Write #              1.71         1.80          7.74        0.89
Input #              0.37         0.26         42.47        0.25
Line Input #         0.21         0.17         42.47        0.19
Binary Line Input#    N/A          N/A          1.37         N/A

The program uses a directory of C:\dave
SO if you are testing it, you will need to create that directory or change to different one.
If you want to the Binary Line Input , you need to set testbinio% = 1


I am thinking that there may be something wrong with my installtion, but before i reinstall again.
Has anybody else experienced with slow i/o performance, or is this just how it is.



Code: QB64: [Select]
  1. sttimer = TIMER
  2.  
  3. doprttest% = 1
  4.  
  5. IF doprttest% = 1 THEN
  6.  
  7.     OPEN "c:\dave\test_pr1.dat" FOR OUTPUT AS #1
  8.  
  9.     DIM datastr$(5)
  10.  
  11.     FOR i& = 1 TO 100000
  12.  
  13.         datastr$(1) = "Data_p1_" + formalt$((i&), "0")
  14.         datastr$(2) = "Data_p2_" + formalt$((i&), "0")
  15.         datastr$(3) = "Data_p3_" + formalt$((i&), "0")
  16.         datastr$(4) = "Data_p4_" + formalt$((i&), "0")
  17.         datastr$(5) = "Data_p5_" + formalt$((i&), "0")
  18.  
  19.  
  20.         PRINT #1, datastr$(1); ","; datastr$(2); ","; datastr$(3); ","; datastr$(4); ","; datastr$(5)
  21.  
  22.     NEXT
  23.  
  24.     CLOSE #1
  25.  
  26.     fitimer = TIMER
  27.  
  28.     timetaken = fitimer - sttimer
  29.     PRINT
  30.     PRINT "test_pri1 (time):-"; formalt$((timetaken), "0.00")
  31.  
  32.  
  33.     sttimer = TIMER
  34.  
  35.     OPEN "c:\dave\test_wr1.dat" FOR OUTPUT AS #1
  36.  
  37.  
  38.     FOR i& = 1 TO 100000
  39.  
  40.         datastr$(1) = "Data_p1_" + formalt$((i&), "0")
  41.         datastr$(2) = "Data_p2_" + formalt$((i&), "0")
  42.         datastr$(3) = "Data_p3_" + formalt$((i&), "0")
  43.         datastr$(4) = "Data_p4_" + formalt$((i&), "0")
  44.         datastr$(5) = "Data_p5_" + formalt$((i&), "0")
  45.  
  46.  
  47.         WRITE #1, datastr$(1), datastr$(2), datastr$(3), datastr$(4), datastr$(5)
  48.  
  49.     NEXT
  50.  
  51.     CLOSE #1
  52.  
  53.     fitimer = TIMER
  54.     timetaken = fitimer - sttimer
  55.     PRINT
  56.     PRINT "test_wri1 (time):-"; formalt$((timetaken), "0.00")
  57.  
  58.     sttimer = TIMER
  59.     OPEN "c:\dave\test_pr1.dat" FOR INPUT AS #1
  60.  
  61.     linecount& = 0
  62.     WHILE NOT EOF(1)
  63.         INPUT #1, datastr$(1), datastr$(2), datastr$(3), datastr$(4), datastr$(5)
  64.         linecount& = linecount& + 1
  65.     WEND
  66.  
  67.     CLOSE #1
  68.  
  69.     fitimer = TIMER
  70.     timetaken = fitimer - sttimer
  71.     PRINT
  72.     PRINT "read using input (time):-"; formalt$((timetaken), "0.00")
  73.     PRINT "linecount&="; linecount&
  74.  
  75.  
  76.     sttimer = TIMER
  77.     OPEN "c:\dave\test_pr1.dat" FOR INPUT AS #1
  78.  
  79.     linecount& = 0
  80.     WHILE NOT EOF(1)
  81.         LINE INPUT #1, tdata$
  82.         linecount& = linecount& + 1
  83.         parsedata% = 0
  84.         IF parsedata% = 1 THEN
  85.             stpos% = 0
  86.             Index% = 1
  87.             DO
  88.                 nextpos% = INSTR(stpos% + 1, tdata$, ",")
  89.                 IF nextpos% > stpos% THEN
  90.                     datastr$(Index%) = MID$(tdata$, stpos% + 1, nextpos% - stpos%)
  91.                     Index% = Index% + 1
  92.                     stpos% = nextpos%
  93.                 ELSE
  94.                     datastr$(Index%) = MID$(tdata$, stpos% + 1)
  95.                     EXIT DO
  96.                 END IF
  97.             LOOP
  98.  
  99.             'FOR dli% = 1 TO 5
  100.             '  PRINT datastr$(dli%)
  101.             'NEXT
  102.             'INPUT s$
  103.         END IF
  104.  
  105.     WEND
  106.  
  107.     CLOSE #1
  108.  
  109.     fitimer = TIMER
  110.     timetaken = fitimer - sttimer
  111.     PRINT
  112.     PRINT "read using line input (time):-"; formalt$((timetaken), "0.00")
  113.     PRINT "linecount&="; linecount&
  114.  
  115. testbinio% = 0
  116. IF testbinio% = 1 THEN
  117.  
  118.     sttimer = TIMER
  119.     OPEN "c:\dave\test_pr1.dat" FOR BINARY AS #1
  120.  
  121.     SEEK #1, 1
  122.  
  123.     loffile& = LOF(1)
  124.     'PRINT "loffile&="; loffile&
  125.     linecount& = 0
  126.     DO
  127.         'IF SEEK(1) < loffile& THEN
  128.         IF NOT EOF(1) THEN
  129.             LINE INPUT #1, tdata$
  130.             'PRINT "Length of data="; LEN(tdata$); "Current file pos="; SEEK(1)
  131.             linecount& = linecount& + 1
  132.  
  133.         ELSE
  134.             'PRINT "Current file pos="; SEEK(1)
  135.             EXIT DO
  136.         END IF
  137.  
  138.     LOOP
  139.     CLOSE #1
  140.  
  141.     fitimer = TIMER
  142.     timetaken = fitimer - sttimer
  143.     PRINT
  144.     PRINT "read using Binary line input (time):-"; formalt$((timetaken), "0.00")
  145.     PRINT "linecount&="; linecount&
  146.  
  147.  
  148. PRINT "press any key to continue"
  149.     a$ = INKEY$
  150. LOOP WHILE a$ = ""
  151.  
  152.  
  153. FUNCTION formalt$ (num AS DOUBLE, precstr$)
  154.     STATIC tnum AS DOUBLE
  155.     dotpos% = INSTR(precstr$, ".")
  156.  
  157.     'PRINT "called ("; num; ","; precstr$; ")"
  158.  
  159.     tnum = num
  160.     IF dotpos% >= 1 THEN
  161.         trailingzeros% = LEN(precstr$) - dotpos%
  162.  
  163.         leadingzeros% = dotpos% - 1
  164.  
  165.         'PRINT dotpos%, trailingzeros%
  166.  
  167.  
  168.         multiplyby& = 10 ^ trailingzeros%
  169.         tempnum& = INT(tnum * multiplyby&)
  170.  
  171.  
  172.  
  173.         tnumstr$ = LTRIM$(RTRIM$(STR$(tempnum&)))
  174.         'PRINT tnumstr$, tempnum&
  175.  
  176.         newtrailingpartnumstr$ = RIGHT$(tnumstr$, trailingzeros%)
  177.         newleadingnumstr$ = LEFT$(tnumstr$, LEN(tnumstr$) - trailingzeros%)
  178.  
  179.  
  180.         numberoffleadingzerostoadd% = leadingzeros% - LEN(newleadingnumstr$)
  181.  
  182.         IF numberoffleadingzerostoadd% > 0 THEN
  183.             addleadingzero$ = STRING$(numberoffleadingzerostoadd%, "0")
  184.         ELSE
  185.             addleadingzero$ = ""
  186.         END IF
  187.  
  188.         newleadingnumstr$ = addleadingzero$ + newleadingnumstr$
  189.  
  190.  
  191.  
  192.         tnumstr$ = newleadingnumstr$ + "." + newtrailingpartnumstr$
  193.  
  194.  
  195.     ELSE
  196.         leadingzeros% = LEN(precstr$)
  197.         tnum = INT(tnum + 0.5)
  198.         trailingzeros% = 0
  199.         tnumstr$ = RTRIM$(LTRIM$(STR$(tnum)))
  200.  
  201.         numberoffleadingzerostoadd% = leadingzeros% - LEN(tnumstr$)
  202.  
  203.         IF numberoffleadingzerostoadd% > 0 THEN
  204.             addleadingzero$ = STRING$(numberoffleadingzerostoadd%, "0")
  205.         ELSE
  206.             addleadingzero$ = ""
  207.         END IF
  208.  
  209.         tnumstr$ = addleadingzero$ + tnumstr$
  210.  
  211.  
  212.     END IF
  213.  
  214.  
  215.     'PRINT tnumstr$
  216.  
  217.     formalt$ = tnumstr$
  218.  
  219.  
  220.  

2
QB64 Discussion / Re: The end of Visual Basic
« on: March 14, 2020, 03:50:37 am »
I have to say when .net came out , I tried converting vb5 programs . The amount of code incompatibilities were huge ( not to mention the huge amount of data / programs / overhead/ slow performance / crap that came with .net framework) so I decided to stick with Vb5. I prefer Vb5 to vb6 because of the bookmark functionality within the IDE. I am so glad I never bothered with VB.net. I still use Vb5 on Windows10 (64bit) and I am using QB64 for about 20 or so programs  that I need to run under 64bit and had never needed to move to Vb5. QB64 is a great tool, only found a couple of incompatibilities so far LPRINT (which is known) and EOF function . I won’t miss Vb5.net but for all those that made the transition to .net it just another kick in the proverbial bollocks from Microsoft .

Pages: [1]