Browse Source

Adding small utility script to measure how long 1s takes.

Alois Mahdal 12 years ago
parent
commit
6253709357
1 changed files with 37 additions and 0 deletions
  1. 37
    0
      bin/timestamp.pl

+ 37
- 0
bin/timestamp.pl View File

@@ -0,0 +1,37 @@
1
+#!/usr/bin/perl -w
2
+
3
+## Author: Alois Mahdal at zxcvb cz
4
+# just measuring one second.
5
+
6
+# This program is free software: you can redistribute it and/or modify
7
+# it under the terms of the GNU General Public License as published by
8
+# the Free Software Foundation, either version 3 of the License, or
9
+# (at your option) any later version.
10
+
11
+# This program is distributed in the hope that it will be useful,
12
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
+# GNU General Public License for more details.
15
+
16
+# You should have received a copy of the GNU General Public License
17
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
+
19
+use warnings;
20
+
21
+use Time::HiRes qw|time|;
22
+use POSIX qw|modf|;
23
+
24
+sub stamp {
25
+    my $time = shift;
26
+    my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = (localtime($time));
27
+    return sprintf "%04i-%02i-%02i %02i:%02i:%02i.%05i", 
28
+                    $year + 1900,   $mon + 1,   $mday,  
29
+                    $hour,          $min,       $sec,     ( modf $time)[0] * 100000;
30
+}
31
+
32
+
33
+while (1) {
34
+    print stamp Time::HiRes::time();
35
+    print "\n";
36
+    sleep 1;
37
+}