Changeset 34 for trunk/epic/test/test_timing.sql
- Timestamp:
- 06/08/09 21:47:59 (3 years ago)
- Files:
-
- 1 modified
-
trunk/epic/test/test_timing.sql (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/epic/test/test_timing.sql
r25 r34 1 1 -- Tests for the timing functions which Epic provides. 2 2 -- To run, execute epic.sql, then this script, then test.run_module('test_timing'). 3 4 CREATE OR REPLACE FUNCTION test._sleep(s double precision) RETURNS VOID AS $$ 5 -- sleep function for Postgres 8.1 6 DECLARE 7 start timestamp with time zone; 8 BEGIN 9 start := timeofday()::timestamp; 10 LOOP 11 EXIT WHEN (timeofday()::timestamp - start) > (s || ' second')::interval; 12 END LOOP; 13 END; 14 $$ LANGUAGE plpgsql; 3 15 4 16 CREATE OR REPLACE FUNCTION test.test_timing() RETURNS VOID AS $$ … … 8 20 BEGIN 9 21 -- Shame we have to use 0.01 but some platforms don't have finer resolution. 10 t := test.timing('SELECT pg_sleep(0.01)', 100);22 t := test.timing('SELECT test._sleep(0.01)', 100); 11 23 12 24 -- Let's assume that sleep(0.01) * 100 should never run *under* 1s
