diff options
author | Debian Live user <user@debian-BULLSEYE-live-builder-AMD64> | 2023-04-28 22:37:57 -0400 |
---|---|---|
committer | Debian Live user <user@debian-BULLSEYE-live-builder-AMD64> | 2023-04-28 22:37:57 -0400 |
commit | 4221ca2879b2d6f10ffe59d1c710b65f3cd6848c (patch) | |
tree | ec1cf887d2e0a389e4485675f3ed45e5831903bd /src | |
parent | ce8bd3eb52b72a9489e41939cc0b98c46454bb52 (diff) |
fix bytes/second io ops calculation
Diffstat (limited to 'src')
-rwxr-xr-x | src/edit-firefox@ | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/src/edit-firefox@ b/src/edit-firefox@ index 2fc99bd..9cf36f3 100755 --- a/src/edit-firefox@ +++ b/src/edit-firefox@ | |||
@@ -1,30 +1,44 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | 2 | ||
3 | TARGET=$1 | 3 | if [ "$1" = -f ] |
4 | then | ||
5 | FORCE=y | ||
6 | shift | ||
7 | fi | ||
8 | |||
9 | if [ $# = 0 ] | ||
10 | then | ||
11 | TARGET=/dev/stderr | ||
12 | else | ||
13 | TARGET=$1 | ||
14 | fi | ||
4 | 15 | ||
5 | die() { printf "%s: Error: %s\n" "$0" "$*" >&2; exit 1; } | 16 | die() { printf "%s: Error: %s\n" "$0" "$*" >&2; exit 1; } |
6 | 17 | ||
7 | # Test DEVICE WRITE OPS BY WRITEOPS | 18 | # uses $DIR |
8 | test_write_ops() | 19 | measure_write_speed() |
9 | { | 20 | { |
10 | if ! [ -e "$1" ] | 21 | if [ "$FORCE" -o ! -e "$1" ] |
11 | then | 22 | then |
12 | mkdir -p "$(dirname "$1")" | 23 | mkdir -p "$(dirname "$1")" |
13 | sync | 24 | sync |
14 | begin=$(date +%s%N) | 25 | begin=$(date +%s%N) |
15 | dd if=/dev/urandom of="$DIR"/urandom.out bs=1M count=300 | 26 | count=500 |
16 | sync | 27 | dd if=/dev/urandom of="$DIR"/urandom.out bs=1M count=$count conv=fdatasync |
17 | end=$(date +%s%N) | 28 | end=$(date +%s%N) |
18 | ops=$(( (end - begin) / 1000000000 )) | 29 | nanosecs=$(( end - begin )) |
30 | millisecs=$(( nanosecs / 1000 / 1000 )) | ||
31 | bytes=$(( count * 1000 * 1000 )) | ||
32 | bytes_per_second=$(( 1000 * bytes / millisecs )) | ||
19 | rm "$DIR"/urandom.out | 33 | rm "$DIR"/urandom.out |
20 | echo "$ops" > "$1" | 34 | printf "Sanity check: megabytes/second = %s\n" \ |
35 | "$(( bytes_per_second / 1000 / 1000 ))" >&2 | ||
36 | printf '%s\n' "$bytes_per_second" > "$1" | ||
21 | fi | 37 | fi |
22 | cat "$1" | 38 | cat "$1" |
23 | } | 39 | } |
24 | 40 | ||
25 | DIR=~/.mozilla | 41 | DIR=~/.mozilla |
26 | READ_OPS=1G | ||
27 | WRITE_OPS=$READ_OPS | ||
28 | CONFDIR=$HOME/.config/firestart | 42 | CONFDIR=$HOME/.config/firestart |
29 | 43 | ||
30 | if [ -e "$CONFDIR"/conf ] | 44 | if [ -e "$CONFDIR"/conf ] |
@@ -32,8 +46,9 @@ then | |||
32 | . "$CONFDIR"/conf | 46 | . "$CONFDIR"/conf |
33 | fi | 47 | fi |
34 | 48 | ||
35 | WRITE_OPS=$(test_write_ops "$CONFDIR"/diskspeed.dat) | 49 | disk_write_speed=$(measure_write_speed "$CONFDIR"/diskspeed.dat) |
36 | WRITE_OPS=${WRITE_OPS%.*} | 50 | |
51 | WRITE_OPS=$(( disk_write_speed / 2 )) | ||
37 | READ_OPS=$WRITE_OPS | 52 | READ_OPS=$WRITE_OPS |
38 | 53 | ||
39 | [ -e "$DIR" ] || die "does not exist: $DIR" | 54 | [ -e "$DIR" ] || die "does not exist: $DIR" |