summaryrefslogtreecommitdiff
path: root/src/generate-firefox-unit
diff options
context:
space:
mode:
Diffstat (limited to 'src/generate-firefox-unit')
-rwxr-xr-xsrc/generate-firefox-unit51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/generate-firefox-unit b/src/generate-firefox-unit
new file mode 100755
index 0000000..c285ffc
--- /dev/null
+++ b/src/generate-firefox-unit
@@ -0,0 +1,51 @@
1#!/bin/bash
2
3INPUT_FILE=$1
4OUTPUT_FILE=$2
5
6die() { printf "%s: Error: %s\n" "$0" "$*" >&2; exit 1; }
7
8# Test DEVICE WRITE OPS BY WRITEOPS
9test_write_ops()
10{
11 if ! [ -e "$1" ]
12 then
13 mkdir -p "$(dirname "$1")"
14 sync
15 begin=$(date +%s%N)
16 dd if=/dev/urandom of="$DIR"/urandom.out bs=1M count=300
17 sync
18 end=$(date +%s%N)
19 ops=$(( (end - begin) / 1000000000 ))
20 rm "$DIR"/urandom.out
21 echo "$ops" > "$1"
22 fi
23 cat "$1"
24}
25
26DIR=~/.mozilla
27READ_OPS=1G
28WRITE_OPS=$READ_OPS
29CONFDIR=$HOME/.config/firestart
30
31if [ -e "$CONFDIR"/conf ]
32then
33 . "$CONFDIR"/conf
34fi
35
36WRITE_OPS=$(test_write_ops "$CONFDIR"/diskspeed.dat)
37WRITE_OPS=${WRITE_OPS%.*}
38READ_OPS=$WRITE_OPS
39
40[ -e "$DIR" ] || die "does not exist: $DIR"
41[ -d "$DIR" ] || die "not a directory: $DIR"
42
43DEV=$(echo $(findmnt --target "$DIR" -o MAJ:MIN -n))
44[ "$DEV" ] || die "could not determine backing device for $DIR"
45
46IOReadIOPSMax="$DEV $READ_OPS"
47IOWriteIOPSMax="$DEV $WRITE_OPS"
48
49sed -e "s/^IOReadIOPSMax *=.*/IOReadIOPSMax = $IOReadIOPSMax/" \
50 -e "s/^IOWriteIOPSMax *=.*/IOWriteIOPSMax = $IOWriteIOPSMax/" \
51 < "$INPUT_FILE" > "$OUTPUT_FILE"