| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# |
|
2
|
|
|
|
|
|
|
# This file is part of Language::Befunge. |
|
3
|
|
|
|
|
|
|
# Copyright (c) 2001-2009 Jerome Quelin, all rights reserved. |
|
4
|
|
|
|
|
|
|
# |
|
5
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify |
|
6
|
|
|
|
|
|
|
# it under the same terms as Perl itself. |
|
7
|
|
|
|
|
|
|
# |
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
package Language::Befunge::lib::HRTI; |
|
11
|
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
4880
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
45
|
|
|
13
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
35
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
1013
|
use Time::HiRes qw{ gettimeofday }; |
|
|
1
|
|
|
|
|
1884
|
|
|
|
1
|
|
|
|
|
5
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
0
|
|
|
0
|
1
|
|
sub new { return bless {}, shift; } |
|
18
|
|
|
|
|
|
|
my %mark; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# -- precision information |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# |
|
24
|
|
|
|
|
|
|
# $n = G() |
|
25
|
|
|
|
|
|
|
# |
|
26
|
|
|
|
|
|
|
# 'Granularity' pushes the smallest clock tick the underlying system can |
|
27
|
|
|
|
|
|
|
# reliably handle, measured in microseconds. |
|
28
|
|
|
|
|
|
|
# |
|
29
|
|
|
|
|
|
|
sub G { |
|
30
|
0
|
|
|
0
|
1
|
|
my ($self, $lbi) = @_; |
|
31
|
|
|
|
|
|
|
# 1 microsecond precision - otherwise, Time::HiRes would have failed |
|
32
|
0
|
|
|
|
|
|
$lbi->get_curip->spush(1); |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# -- time measurements |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# |
|
39
|
|
|
|
|
|
|
# M() |
|
40
|
|
|
|
|
|
|
# |
|
41
|
|
|
|
|
|
|
# 'Mark' designates the timer as having been read by the IP with this ID at |
|
42
|
|
|
|
|
|
|
# this instance in time. |
|
43
|
|
|
|
|
|
|
# |
|
44
|
|
|
|
|
|
|
sub M { |
|
45
|
0
|
|
|
0
|
1
|
|
my ($self, $lbi) = @_; |
|
46
|
0
|
|
|
|
|
|
my $ip = $lbi->get_curip; |
|
47
|
0
|
|
|
|
|
|
my $id = $ip->get_id; |
|
48
|
0
|
|
|
|
|
|
$mark{$id} = gettimeofday(); |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# |
|
53
|
|
|
|
|
|
|
# $microseconds = T() |
|
54
|
|
|
|
|
|
|
# |
|
55
|
|
|
|
|
|
|
# 'Timer' pushes the number of microseconds elapsed since the last time an |
|
56
|
|
|
|
|
|
|
# IP with this ID marked the timer. If there is no previous mark, acts like |
|
57
|
|
|
|
|
|
|
# r. |
|
58
|
|
|
|
|
|
|
# |
|
59
|
|
|
|
|
|
|
sub T { |
|
60
|
0
|
|
|
0
|
1
|
|
my ($self, $lbi) = @_; |
|
61
|
0
|
|
|
|
|
|
my $ip = $lbi->get_curip; |
|
62
|
0
|
|
|
|
|
|
my $id = $ip->get_id; |
|
63
|
0
|
0
|
|
|
|
|
if ( not exists $mark{$id} ) { |
|
64
|
0
|
|
|
|
|
|
$ip->dir_reverse; |
|
65
|
0
|
|
|
|
|
|
return; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
0
|
|
|
|
|
|
my $secs = gettimeofday() - $mark{$id}; |
|
68
|
0
|
|
|
|
|
|
$ip->spush( int($secs * 1000) ); |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# |
|
73
|
|
|
|
|
|
|
# E() |
|
74
|
|
|
|
|
|
|
# |
|
75
|
|
|
|
|
|
|
# 'Erase mark' erases the last timer mark by this IP (such that 'T' above |
|
76
|
|
|
|
|
|
|
# will act like r. |
|
77
|
|
|
|
|
|
|
# |
|
78
|
|
|
|
|
|
|
sub E { |
|
79
|
0
|
|
|
0
|
1
|
|
my ($self, $lbi) = @_; |
|
80
|
0
|
|
|
|
|
|
my $ip = $lbi->get_curip; |
|
81
|
0
|
|
|
|
|
|
my $id = $ip->get_id; |
|
82
|
0
|
|
|
|
|
|
delete $mark{$id}; |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# |
|
87
|
|
|
|
|
|
|
# $microseconds = S() |
|
88
|
|
|
|
|
|
|
# |
|
89
|
|
|
|
|
|
|
# 'Second' pushes the number of microseconds elapsed since the last whole |
|
90
|
|
|
|
|
|
|
# second. |
|
91
|
|
|
|
|
|
|
# |
|
92
|
|
|
|
|
|
|
sub S { |
|
93
|
0
|
|
|
0
|
1
|
|
my ($self, $lbi) = @_; |
|
94
|
0
|
|
|
|
|
|
my (undef, $msecs) = gettimeofday(); |
|
95
|
0
|
|
|
|
|
|
$lbi->get_curip->spush( $msecs ); |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
1; |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
__END__ |