DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400 Tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Rational R1000/400 Tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: B T

⟦5f2e7f03e⟧ TextFile

    Length: 4359 (0x1107)
    Types: TextFile
    Names: »B«

Derivation

└─⟦180fe333a⟧ Bits:30000405 8mm tape, Rational 1000, SW CATALOG, 10_20_0
└─⟦180fe333a⟧ Bits:30000537 8mm tape, Rational 1000, SW Catalog 10_20_0
    └─⟦5cb1d1d7f⟧ »DATA« 
        └─⟦3b1ee7bd8⟧ 
            └─⟦this⟧ 

TextFile

--
-- Version: @(#)char_dir.ada 1.2  Date: 9/21/84
--
-- Author:  Edward Colbert
--     Ada Technology Group
--     Information Software Systems Lab
--     Defense Systems Group
--     TRW
--     Redondo Beach, CA
--
-- This program measures the time required for doing various file
-- operations using the Direct_IO package with Characters.
--
-- Note:  In order for the measurement to be meaningful, it must be the
-- only program executing while the test is run.
--
-- Please set Times large enough to provide at least two significant
-- digits in the average times, i.e., the difference between
-- the elapsed time and the loop time must be at least 100 times
-- Duration'Small & at least 100 times System.Tick.
--

with Text_Io;
use Text_Io;
with Direct_Io;
with Calendar;
use Calendar;
with System;
use System;
procedure Character_Direct_Io_Test is

    Times : constant Positive := 1000;

    type Real_Time is digits Max_Digits;

    Start_Time : Time;
    Loop_Time : Duration;
    Average_Time : Real_Time;
    Create_Time : Duration;
    Close_Time : Duration;
    Open_Time : Duration;
    Delete_Time : Duration;
    Read_Time : Duration;
    Write_Time : Duration;

    package Duration_Io is new Fixed_Io (Duration);
    use Duration_Io;

    package Real_Time_Io is new Float_Io (Real_Time);
    use Real_Time_Io;

    package Int_Io is new Integer_Io (Integer);
    use Int_Io;

    package Char_Io is new Direct_Io (Character);
    use Char_Io;

    File : Char_Io.File_Type;
    Value : Character := 'A';
    Count : Integer := Integer'First;  -- used in timing loop

begin

    -- Measure the timing loop overhead.
    Start_Time := Clock;

    for N in 1 .. Times loop
        Count := Count + 1;                 -- prevent optimization
    end loop;

    Loop_Time := Clock - Start_Time;


    -- Create a file
    Start_Time := Clock;
    Char_Io.Create (File, Mode => Out_File, Name => "test_file");
    Create_Time := Clock - Start_Time;

    -- Measure the time of Writing of value
    Start_Time := Clock;

    for N in 1 .. Times loop
        Count := Count + 1;
        Char_Io.Write (File, Value);
    end loop;

    Write_Time := Clock - Start_Time;

    -- Close a file
    Start_Time := Clock;
    Char_Io.Close (File);
    Close_Time := Clock - Start_Time;

    -- Open a file
    Start_Time := Clock;
    Char_Io.Open (File, Mode => In_File, Name => "test_file");
    Open_Time := Clock - Start_Time;

    -- Measure the time of Reading of value
    Start_Time := Clock;

    for N in 1 .. Times loop
        Count := Count + 1;
        Char_Io.Read (File, Value);
    end loop;

    Read_Time := Clock - Start_Time;

    -- Delete a file
    Start_Time := Clock;
    Char_Io.Delete (File);
    Delete_Time := Clock - Start_Time;


    Put ("Create File Time = ");
    Put (Create_Time, Fore => 0);
    Put_Line (" seconds ");

    Put ("Close File Time = ");
    Put (Close_Time, Fore => 0);
    Put_Line (" seconds ");

    Put ("Open File Time = ");
    Put (Open_Time, Fore => 0);
    Put_Line (" seconds ");

    Put ("Delete File Time = ");
    Put (Delete_Time, Fore => 0);
    Put_Line (" seconds ");

    Put ("Loop time = ");
    Put (Loop_Time, Fore => 0);
    Put (" seconds for ");
    Put (Times, Width => 0);
    Put_Line (" iterations");


    Put ("Elapsed time = ");
    Put (Write_Time, Fore => 0);
    Put (" seconds for ");
    Put (Times, Width => 0);
    Put_Line (" Writes");

    Average_Time := Real_Time (Write_Time - Loop_Time) / Real_Time (Times);
    Put ("Average time for a Write = ");
    Put (Average_Time, Fore => 0);
    Put_Line (" seconds");

    New_Line;



    Put ("Elapsed time = ");
    Put (Read_Time, Fore => 0);
    Put (" seconds for ");
    Put (Times, Width => 0);
    Put_Line (" Reads");

    Average_Time := Real_Time (Read_Time - Loop_Time) / Real_Time (Times);
    Put ("Average time for a Read = ");
    Put (Average_Time, Fore => 0);
    Put_Line (" seconds");

    New_Line;

    if (Read_Time - Loop_Time < 100 * Duration'Small) or
       (Read_Time - Loop_Time < 100 * System.Tick) or
       (Write_Time - Loop_Time < 100 * Duration'Small) or
       (Write_Time - Loop_Time < 100 * System.Tick) then
        Put_Line ("** TEST FAILED (due to insufficient precision)! **");
    else
        Put_Line ("** TEST PASSED **");
    end if;

end Character_Direct_Io_Test;