We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 965acc0 + 73b6867 commit 288c820Copy full SHA for 288c820
cache
@@ -38,6 +38,23 @@ cache::normalize_string() {
38
echo "$result"
39
}
40
41
+cache::current_timestamp_in_milis() {
42
+ DIST=$(uname)
43
+
44
+ case $DIST in
45
+ Darwin)
46
+ gdate +%s%3N
47
+ ;;
48
+ Linux)
49
+ date +%s%3N
50
51
+ *)
52
+ echo "Unsupported distro $DIST"
53
+ exit 1
54
55
+ esac
56
+}
57
58
cache::duration() {
59
60
local lftp_cmd
@@ -46,9 +63,9 @@ cache::duration() {
63
local duration
64
65
lftp_cmd=$1; shift
- start=$(date +%s%3N)
66
+ start=$(cache::current_timestamp_in_milis)
67
$lftp_cmd "$@"
- end=$(date +%s%3N)
68
+ end=$(cache::current_timestamp_in_milis)
69
duration=$(( $end - $start ))
70
71
echo $duration > /tmp/duration
0 commit comments