with Instrument;
use Instrument;

------------------
-- Parameterless Call
------------------

-- This test evaluates the efficiency of a call to a procedure that has
-- no formal parameters.

-- The parameterless procedure Inner is used in the procedure call and
-- when executed assigns a value to a local variable, which is then
-- assigned to the global variable.  In the test version Inner is called
-- twice, while in the noise version one of the calls is replaced by
-- identical assignments (Lets) to a local and the global variable.  The
-- additional call to Inner ensures that the compiler does not eliminate
-- Inner from the noise version as a part of dead code optimization.
-- Similarly, the local variable Outer_Local is referenced in the test
-- version to preclude its elimination.

procedure Nppca1 is
    package Ps_Cs is new Procs (Integer);
    use Ps_Cs;

    Outer_Local : T;

    procedure Inner is
        Inner_Local : T;
    begin
        Let (Inner_Local, Ident (Init));
        Let (Global, Ident (Inner_Local));
    end Inner;

begin

    Start ("NPPCA1", "No Parameter Procedure Call (Control)");
    for I in 1 .. 10000 loop


        Let (Outer_Local, Ident (Init));
        Inner;                                   -- called in both versions
        Let (Global, Ident (Outer_Local));

        --    Inner;                                 -- included in test version
        Let (Outer_Local, Ident (Init));         -- in both versions
        Let (Global, Ident (Global));       -- included in control version
        Let (Global, Ident (Outer_Local));  -- included in control version

    end loop;
    Stop;

end Nppca1;