Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions Magisk Template/customize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,13 @@ ui_print " - Please wait..."
gpu_cache_cleaner() {
if [ $# -gt 0 ]; then
# Remove shader cache directories and GPU cache files
find "$@" \( \
find "$@" \
-type d \( -name '*shader_cache*' -o -name '*gpu_cache*' \) -prune -exec rm -rf {} + \
\) -o \( \
-type f \( -name '*shader*' -o -name '*gpu_cache*' \) -exec rm -f {} + \
\) 2>/dev/null || true
2>/dev/null || true

find "$@" \
-type f \( -name '*shader*' -o -name '*gpu_cache*' \) -delete \
2>/dev/null || true

for path in "$@"; do
if [ -d "$path" ]; then
Expand Down
69 changes: 69 additions & 0 deletions tests/benchmark.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash

BASE_DIR="benchmark_data"

# Function to create test files
create_files() {
local count=$1
echo "Creating mixed content..."
# 5000 loose files
for i in $(seq 1 5000); do
touch "$BASE_DIR/loose_shader_$i.bin"
done

# 100 directories to be deleted, each with 50 files
for i in $(seq 1 100); do
mkdir -p "$BASE_DIR/dir_$i/shader_cache"
for j in $(seq 1 50); do
touch "$BASE_DIR/dir_$i/shader_cache/file_$j"
done

# Also some non-deleted dirs with files
mkdir -p "$BASE_DIR/dir_$i/normal"
for j in $(seq 1 50); do
touch "$BASE_DIR/dir_$i/normal/file_$j"
done
done
}

cleanup() {
rm -rf "$BASE_DIR"
}

run_benchmark() {
local mode=$1
echo "Running benchmark for mode: $mode"

# Re-create files for each run
cleanup
mkdir -p "$BASE_DIR"
create_files

start_time=$(date +%s%N)

if [ "$mode" == "original" ]; then
find "$BASE_DIR" \( \
-type d \( -name '*shader_cache*' -o -name '*gpu_cache*' \) -prune -exec rm -rf {} + \
\) -o \( \
-type f \( -name '*shader*' -o -name '*gpu_cache*' \) -exec rm -f {} + \
\) 2>/dev/null || true
elif [ "$mode" == "split" ]; then
# First pass: Directories with prune
find "$BASE_DIR" \
-type d \( -name '*shader_cache*' -o -name '*gpu_cache*' \) -prune -exec rm -rf {} + \
2>/dev/null || true
# Second pass: Files with delete
find "$BASE_DIR" \
-type f \( -name '*shader*' -o -name '*gpu_cache*' \) -delete \
2>/dev/null || true
fi

end_time=$(date +%s%N)
duration=$((end_time - start_time))
echo "Duration (ns): $duration"
}

run_benchmark "original"
run_benchmark "split"

cleanup