Wednesday | 04 DEC 2024
[ previous ]
[ next ]

READSEQ vs READBLK

Title:
Date: 2024-01-16
Tags:  pick, UniVerse

Table of Contents

  1. READSEQ
  2. READBLK

As one would guess reading an entire file into memory in one shot is faster than going line by line.

Still good to always prove things.

READSEQ - 2.6862s 
READBLK - 0.0131s

READSEQ

*
   EQU TRUE TO 1
   EQU FALSE TO 0
*
   FILE.NAME = 'measurements-med.txt'
*
   PATH = '/home/transfer/' : FILE.NAME
*
   T1 = TIME()
*
   OPENSEQ PATH TO FLAT.FILE ELSE
      PRINT 'Unable to open: ' : PATH
      STOP
   END
*
   DONE = FALSE
*
   LOOP
      READSEQ RAW.LINE FROM FLAT.FILE ELSE DONE = TRUE
   UNTIL DONE DO
*
   REPEAT
*
   T2 = TIME()
*
   PRINT 'Loading: ' : T2 - T1 : 's'
*
* END OF PROGRAM
*
   END
*

READBLK

*
   EQU TRUE TO 1
   EQU FALSE TO 0
*
   FILE.NAME = 'measurements-med.txt'
*
   PATH = '/home/transfer/' : FILE.NAME
*
   T1 = TIME()
*
   OPENSEQ PATH TO FLAT.FILE ELSE
      PRINT 'Unable to open: ' : PATH
      STOP
   END
*
   READBLK RAW.DATA FROM FLAT.FILE, 2000000000 THEN
      RELEASE FLAT.FILE
      CLOSESEQ FLAT.FILE
   END
*
   T2 = TIME()
*
   PRINT 'Loading: ' : T2 - T1 : 's'
*
* END OF PROGRAM
*
   END
*