This is an old revision of the document!


Good text I/O practice

The Ada standard libraries provides a general purpose text I/O package named Ada.Text_IO. This is good for small problems where efficiency is not an issue, and its parsing and formatting routines are excellent. One of the challenges for the compiler writers is that Ada.Text_IO is required to keep track of column, line and page numbers. ATest runs of the examples at <http://rosettacode.org/wiki/Read_entire_file#Ada> on three different text files (respectively 1 Mb, 32 Mb and 1024 Mb in size):

Using Unbounded_Strings:


1024 kb ./using_unbounded_strings > copy 0,02s user 0,27s system 16% cpu 1,836 total ./using_unbounded_strings > copy 0,02s user 0,01s system 91% cpu 0,031 total ./using_unbounded_strings > copy 0,02s user 0,02s system 96% cpu 0,046 total

32 Mb ./using_unbounded_strings > copy 0,68s user 0,41s system 38% cpu 2,809 total ./using_unbounded_strings > copy 0,70s user 0,40s system 99% cpu 1,100 total ./using_unbounded_strings > copy 0,71s user 0,34s system 99% cpu 1,067 total

1024 Mb ./using_unbounded_strings > copy 20,99s user 11,72s system 96% cpu 33,861 total ./using_unbounded_strings > copy 21,07s user 11,83s system 90% cpu 36,170 total ./using_unbounded_strings > copy 21,28s user 12,15s system 73% cpu 45,767 total

Using Direct_IO:


1024 kb ./using_direct_io > copy 0,00s user 0,00s system 68% cpu 0,006 total ./using_direct_io > copy 0,01s user 0,01s system 84% cpu 0,019 total ./using_direct_io > copy 0,00s user 0,00s system 64% cpu 0,012 total

32 Mb raised STORAGE_ERROR : stack overflow (or erroneous memory access) raised STORAGE_ERROR : stack overflow (or erroneous memory access) raised STORAGE_ERROR : stack overflow (or erroneous memory access)

1024 Mb raised STORAGE_ERROR : stack overflow (or erroneous memory access) raised STORAGE_ERROR : stack overflow (or erroneous memory access) raised STORAGE_ERROR : stack overflow (or erroneous memory access)

Using recursion:


1024 kb raised STORAGE_ERROR : stack overflow (or erroneous memory access) raised STORAGE_ERROR : stack overflow (or erroneous memory access) raised STORAGE_ERROR : stack overflow (or erroneous memory access)

32 Mb raised STORAGE_ERROR : stack overflow (or erroneous memory access) raised STORAGE_ERROR : stack overflow (or erroneous memory access) raised STORAGE_ERROR : stack overflow (or erroneous memory access)

1024 Mb raised STORAGE_ERROR : stack overflow (or erroneous memory access) raised STORAGE_ERROR : stack overflow (or erroneous memory access) raised STORAGE_ERROR : stack overflow (or erroneous memory access)

Using Memory_Mapping:


1024 kb ./using_memory_maps > copy 0,00s user 0,24s system 71% cpu 0,347 total ./using_memory_maps > copy 0,00s user 0,00s system 85% cpu 0,005 total ./using_memory_maps > copy 0,00s user 0,01s system 74% cpu 0,011 total

32 Mb ./using_memory_maps > copy 0,00s user 0,07s system 79% cpu 0,086 total ./using_memory_maps > copy 0,00s user 0,07s system 96% cpu 0,075 total ./using_memory_maps > copy 0,00s user 0,06s system 94% cpu 0,068 total

1024 Mb ./using_memory_maps > copy 0,00s user 1,38s system 42% cpu 3,227 total ./using_memory_maps > copy 0,00s user 1,63s system 91% cpu 1,776 total ./using_memory_maps > copy 0,00s user 1,62s system 88% cpu 1,840 total


Navigation