summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDebian Live user <user@debian-BULLSEYE-live-builder-AMD64>2023-04-28 22:37:57 -0400
committerDebian Live user <user@debian-BULLSEYE-live-builder-AMD64>2023-04-28 22:37:57 -0400
commit4221ca2879b2d6f10ffe59d1c710b65f3cd6848c (patch)
treeec1cf887d2e0a389e4485675f3ed45e5831903bd
parentce8bd3eb52b72a9489e41939cc0b98c46454bb52 (diff)
fix bytes/second io ops calculation
-rwxr-xr-xsrc/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
3TARGET=$1 3if [ "$1" = -f ]
4then
5 FORCE=y
6 shift
7fi
8
9if [ $# = 0 ]
10then
11 TARGET=/dev/stderr
12else
13 TARGET=$1
14fi
4 15
5die() { printf "%s: Error: %s\n" "$0" "$*" >&2; exit 1; } 16die() { printf "%s: Error: %s\n" "$0" "$*" >&2; exit 1; }
6 17
7# Test DEVICE WRITE OPS BY WRITEOPS 18# uses $DIR
8test_write_ops() 19measure_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
25DIR=~/.mozilla 41DIR=~/.mozilla
26READ_OPS=1G
27WRITE_OPS=$READ_OPS
28CONFDIR=$HOME/.config/firestart 42CONFDIR=$HOME/.config/firestart
29 43
30if [ -e "$CONFDIR"/conf ] 44if [ -e "$CONFDIR"/conf ]
@@ -32,8 +46,9 @@ then
32 . "$CONFDIR"/conf 46 . "$CONFDIR"/conf
33fi 47fi
34 48
35WRITE_OPS=$(test_write_ops "$CONFDIR"/diskspeed.dat) 49disk_write_speed=$(measure_write_speed "$CONFDIR"/diskspeed.dat)
36WRITE_OPS=${WRITE_OPS%.*} 50
51WRITE_OPS=$(( disk_write_speed / 2 ))
37READ_OPS=$WRITE_OPS 52READ_OPS=$WRITE_OPS
38 53
39[ -e "$DIR" ] || die "does not exist: $DIR" 54[ -e "$DIR" ] || die "does not exist: $DIR"