Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
eepm
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
eepm
Commits
50af49fa
Commit
50af49fa
authored
Feb 23, 2026
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eget: use nanosecond integer timing in speedtest
parent
850e8fd4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
5 deletions
+18
-5
tools_eget
bin/tools_eget
+18
-5
No files found.
bin/tools_eget
View file @
50af49fa
...
@@ -350,6 +350,19 @@ __calc_avg_filtered()
...
@@ -350,6 +350,19 @@ __calc_avg_filtered()
}'
}'
}
}
# Get current time in nanoseconds (integer) for precise timing
# Falls back to seconds if %N is not supported (BusyBox)
__get_time_ns
()
{
local
t
t
=
$(
date
+%s%N 2>/dev/null
)
# If %N not supported, date outputs literal 'N' — fall back to seconds
case
"
$t
"
in
*
N
*
)
echo
"
$(
date
+%s
)
000000000"
;;
*
)
echo
"
$t
"
;;
esac
}
# Single speedtest measurement with timeout (returns speed in MB/s)
# Single speedtest measurement with timeout (returns speed in MB/s)
# Downloads to temp file using eget, counts bytes with pv or wc -c
# Downloads to temp file using eget, counts bytes with pv or wc -c
# Args: URL [timeout] [total_size]
# Args: URL [timeout] [total_size]
...
@@ -361,7 +374,7 @@ __speedtest_single()
...
@@ -361,7 +374,7 @@ __speedtest_single()
local
tmpfile start_time end_time size
local
tmpfile start_time end_time size
tmpfile
=
$(
mktemp
)
tmpfile
=
$(
mktemp
)
start_time
=
$(
date
+%s.%N
)
start_time
=
$(
__get_time_ns
)
if
[
-n
"
$verbose
"
]
&&
which pv
>
/dev/null 2>&1
;
then
if
[
-n
"
$verbose
"
]
&&
which pv
>
/dev/null 2>&1
;
then
# pv shows progress to stderr (-s for total size if known)
# pv shows progress to stderr (-s for total size if known)
local
pv_opts
=
"-f"
local
pv_opts
=
"-f"
...
@@ -370,14 +383,14 @@ __speedtest_single()
...
@@ -370,14 +383,14 @@ __speedtest_single()
else
else
eget
-q
--force
-T
"
$timeout
"
-O
"
$tmpfile
"
"
$URL
"
2>/dev/null
||
true
eget
-q
--force
-T
"
$timeout
"
-O
"
$tmpfile
"
"
$URL
"
2>/dev/null
||
true
fi
fi
end_time
=
$(
date
+%s.%N
)
end_time
=
$(
__get_time_ns
)
size
=
$(
wc
-c
<
"
$tmpfile
"
)
size
=
$(
wc
-c
<
"
$tmpfile
"
)
rm
-f
"
$tmpfile
"
rm
-f
"
$tmpfile
"
# Calculate speed: size / time in MB/s
# Calculate speed: size / time
_ns
in MB/s
echo
"
$size
$start_time
$end_time
"
|
awk
'{
echo
"
$size
$start_time
$end_time
"
|
awk
'{
time = $3 - $2
time
_ns
= $3 - $2
if (time
> 0) printf "%.2f", ($1 / time
) / 1024 / 1024
if (time
_ns > 0) printf "%.2f", ($1 / (time_ns / 1000000000)
) / 1024 / 1024
else print "0"
else print "0"
}'
}'
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment