(* Copyright (C) 1990, Digital Equipment Corporation. *) (* All rights reserved. *) (* See the file COPYRIGHT for a full description. *) (* Last modified on Tue Apr 24 23:15:42 1990 by muller *) (* modified on Mon Mar 12 11:58:00 1990 by mcjones *) MODULE TimeSTable EXPORTS Main; IMPORT Fmt, GCHacks, SIntTable, STextTable, Stdio, Text, TextWr, Time, Wr; PROCEDURE PrintTimes(elapsed: Time.T) = VAR elapsedTenths: CARDINAL := (elapsed.microseconds + 50000) DIV 100000; BEGIN Wr.PutText (Stdio.stdout, Fmt.Int (elapsed.seconds) & "." & Fmt.Int( elapsedTenths) & " seconds") END PrintTimes; PROCEDURE TimeInts(N: CARDINAL) = VAR t0, t1: Time.T; t: SIntTable.T; key: SIntTable.Key; s: SIntTable.Stream; v: SIntTable.Value; BEGIN t0 := Time.Now(); t := SIntTable.New (); FOR i := 1 TO N DO EVAL SIntTable.Put (t, 2 * i, NIL) END; FOR i := 1 TO N DO EVAL SIntTable.Get (t, 2 * i, v); EVAL SIntTable.Get (t, 2 * i + 1, v) END; s := SIntTable.NewStream (t, TRUE, 1 * 2); WHILE SIntTable.Next (s, key, v) DO END; s := SIntTable.NewStream (t, FALSE, 2 * N); WHILE SIntTable.Next (s, key, v) DO END; FOR i := 1 TO N DO EVAL SIntTable.Delete (t, 2 * i, v) END; SIntTable.Clear (t); t1 := Time.Now(); Wr.PutText (Stdio.stdout, "TimeInts( N := " & Fmt.Int (N) & " ) took "); PrintTimes(Time.Subtract(t1, t0)); Wr.PutText(Stdio.stdout, ".\n") END TimeInts; BEGIN Wr.PutText(Stdio.stdout, "Default garbage collection:\n"); TimeInts( 2048); TimeInts( 4096); TimeInts( 8192); TimeInts(16384); TimeInts(32768); (*Wr.PutText(Stdio.stdout, "SetGCIncrement(131072):\n"); GCHacks.SetGCIncrement(131072); TimeInts( 2048); TimeInts( 4096); TimeInts( 8192); TimeInts(16384); TimeInts(32768); Wr.PutText(Stdio.stdout, "No garbage collection:\n"); GCHacks.DisableGC(); TimeInts( 2048); TimeInts( 4096); TimeInts( 8192); TimeInts(16384); TimeInts(32768) *) END TimeSTable.