package RDA::Extern::TimeChk; # $Id: TimeChk.pm,v 1.4 2009/01/13 17:05:59 mschenke Exp $ # ARCS: $Header: /u02/webapps/workbench/cvs/RDA_4/src/scripting/lib/RDA/Extern/TimeChk.pm,v 1.4 2009/01/13 17:05:59 mschenke Exp $ # # Change History # 20090113 MSC Change the copyright notice. =head1 NAME RDA::Extern::Timecheck - Time Check Routines =head1 SYNOPSIS require RDA::Extern::TimeChk; =head1 DESCRIPTION The following method is available: =cut use strict; =head2 S This method checks for monotonically increasing time. You can specify the number of clock checks as an argument. It does 1000000 tests by default. It returns an empty string on successful completion, or an error message otherwise. =cut sub check_clock { my ($ctx, $cnt) = @_; my ($cur, $dif, $prv); eval "require Time::HiRes"; return "Not available: $@" if $@; $cnt = 1000000 unless defined($cnt); $prv = [Time::HiRes::gettimeofday()]; for (1..$cnt) { $cur = [Time::HiRes::gettimeofday()]; return sprintf('Time went backwards: %d.%06d -> %d.%06d', @$prv, @$cur) if Time::HiRes::tv_interval($prv, $cur) < 0; $prv = $cur; } ''; } 1; =head1 COPYRIGHT NOTICE Copyright (c) 2002-2009, Oracle. All rights reserved. =head1 TRADEMARK NOTICE Oracle, JD Edwards, PeopleSoft, and Siebel are registered trademarks of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. =cut