-
Notifications
You must be signed in to change notification settings - Fork 23
/
prepare.sh
executable file
·39 lines (31 loc) · 1.07 KB
/
prepare.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/sh
#
# libconfini/dev/tests/performance/prepare.sh
#
_SCRIPTPATH="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
_TMPFILE="$(mktemp)"
cd "${_SCRIPTPATH}"
CATSRC='../../../examples/ini_files/self_explaining.conf'
CATDEST='big_file.ini'
CCPROG='gcc'
CSRC='performance.c'
COUT='speedtest'
# Careful with this number, it's an exponent!
DOUBLINGS=15
read -p '**WARNING** This script will generate an INI file '$(($(stat --printf="%s" "${CATSRC}") * (1 << "${DOUBLINGS}")))' bytes large. Do you'$'\n'' wish to proceed? (y/N) ' -n1 _ANSW_
[[ "${_ANSW_}" == "${EOF}" ]] || echo
[[ "${_ANSW_,,}" == 'y' ]] || exit 0
echo "$(echo; cat $CATSRC)" > "${CATDEST}"
while ((DOUBLINGS > 0)); do
cat "${CATDEST}" "${CATDEST}" > "${_TMPFILE}" && mv "${_TMPFILE}" "${CATDEST}"
((DOUBLINGS--))
done
if "${CCPROG}" -lconfini -pedantic -o "${COUT}" "${CSRC}"; then
echo "File \"${CATDEST}\" has been created. Now launch the \`${COUT}\` program"
echo 'generated'
else
echo
echo "File \"${CATDEST}\" has been created, but an error occured while trying to"
echo "compile \"${CSRC}\""
fi
# EOF