-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
48 lines (43 loc) · 1.56 KB
/
run.sh
File metadata and controls
48 lines (43 loc) · 1.56 KB
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
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
# 1. Compiling the sorting implementation - Choose the corresponding one
mkdir -p ./build
# 1) Dumb
# g++ -std=c++20 -Wall ./src/sort/dumb.cpp -o ./build/sort
# 2) Mapped
# g++ -std=c++20 -Wall ./src/sort/mapped.cpp -o ./build/sort
# 3) External
g++ -std=c++20 -Wall \
./src/sort/external/binary_heap/binary_heap.cpp \
./src/sort/external/queue/queue.cpp \
./src/sort/external/init.cpp \
./src/sort/external/main.cpp \
./src/sort/external/sort.cpp \
-o ./build/sort
# 2. Clearing all the FS buffers / caches (Preventing cached file-data from being used)
sudo sync
echo 3 | sudo tee /proc/sys/vm/drop_caches >/dev/null
# 3. Initializing a C-Group and joining it (Resetting if necessary)
CGROUP=/sys/fs/cgroup/test
sudo rmdir $CGROUP 2>/dev/null
sudo mkdir $CGROUP
echo $$ | sudo tee "$CGROUP/cgroup.procs" >/dev/null
echo $(( 10 * 1024 * 1024 )) | sudo tee "$CGROUP/memory.max" >/dev/null
# 4. Running the actual sorting with timing
time ./build/sort ./workspace/data 33000000 ./workspace "$(( 9 * 1024 * 1024 ))"
RESULT_CODE="$?"
if [ "$RESULT_CODE" == "1" ]; then
echo "FAILED"
exit 1
fi
if [ "$RESULT_CODE" == "137" ]; then
echo "KILLED"
exit 1
fi
# 5. Outputting memory / IO stats recorded by the C-Group
echo ""
echo "STATS"
echo "Total memory: $(cat "$CGROUP/memory.peak")"
echo "Swap memory: $(cat "$CGROUP/memory.swap.peak")"
# Does NOT show the peak, just the current memory-usage (Can already have the data-file evicted)
echo "FS memory: $(cat "$CGROUP/memory.stat" | grep "^file " | awk -F ' ' '{print $2}')"
echo "IOs: $(cat "$CGROUP/io.stat")"