add primed.sh
a shell script to calculate prime numbers, as a benchmark
This commit is contained in:
parent
5a06ec7e41
commit
c6075c72d2
1 changed files with 20 additions and 0 deletions
20
primed.sh
Normal file
20
primed.sh
Normal file
|
@ -0,0 +1,20 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Number of CPU-intensive tasks to run
|
||||
num_tasks=4
|
||||
|
||||
# Function to perform CPU-intensive calculations
|
||||
perform_calculations() {
|
||||
while true; do
|
||||
result=$(echo "scale=10000; 4*a(1)" | bc -l)
|
||||
result=$(echo "scale=10000; sqrt($result^2)" | bc -l)
|
||||
done
|
||||
}
|
||||
|
||||
# Run multiple CPU-intensive tasks in parallel
|
||||
for ((i = 0; i < num_tasks; i++)); do
|
||||
perform_calculations &
|
||||
done
|
||||
|
||||
# Wait for all tasks to complete
|
||||
wait
|
Loading…
Add table
Reference in a new issue