home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / CPROG / V11N10.ZIP / BINARY.BAS next >
BASIC Source File  |  1991-03-29  |  1KB  |  44 lines

  1. 'BINARY.BAS - benchmark to compare Binary and Sequential access
  2.  
  3. Start! = TIMER
  4. OPEN "STANDARD.DAT" FOR OUTPUT AS #1
  5. FOR X% = 1 TO 5000
  6.     PRINT #1, X%
  7. NEXT
  8. CLOSE #1
  9. Done! = TIMER
  10. PRINT USING "##.### seconds to write a sequential file"; Done! - Start!
  11.  
  12. Start! = TIMER
  13. OPEN "BINARY.DAT" FOR BINARY AS #1
  14. FOR X% = 1 TO 5000
  15.     PUT #1, , X%
  16. NEXT
  17. CLOSE #1
  18. Done! = TIMER
  19. PRINT USING "##.### seconds to write a binary file"; Done! - Start!
  20.  
  21. Start! = TIMER
  22. OPEN "STANDARD.DAT" FOR INPUT AS #1
  23. FOR X% = 1 TO 5000
  24.     INPUT #1, X%
  25. NEXT
  26. StandardLen& = LOF(1)
  27. CLOSE #1
  28. Done! = TIMER
  29. PRINT USING "##.### seconds to read a sequential file"; Done! - Start!
  30.  
  31. Start! = TIMER
  32. OPEN "BINARY.DAT" FOR BINARY AS #1
  33. FOR X% = 1 TO 5000
  34.     GET #1, , X%
  35. NEXT
  36. BinaryLen& = LOF(1)
  37. CLOSE #1
  38. Done! = TIMER
  39. PRINT USING "##.### seconds to read a binary file"; Done! - Start!
  40.  
  41. PRINT "The standard sequential file is"; StandardLen&; "bytes long."
  42. PRINT "             The binary file is"; BinaryLen&; "bytes long."
  43.  
  44.