Skip to content
Permalink
Browse files

Add single-threaded benchmark

  • Loading branch information...
NEMS Linux
NEMS Linux committed Jun 5, 2019
1 parent 8082ec1 commit c9f06e062e3411020fefd577d53e17bc6d891959
Showing with 101 additions and 5 deletions.
  1. +50 −0 benchmark-parsecores.sh
  2. +41 −3 benchmark.sh
  3. +8 −1 info.sh
  4. +2 −1 stats.sh
@@ -0,0 +1,50 @@
#!/usr/bin/env php
<?php
// This little script will simply reply to a core switch with how many cores are on that CPU
// For example, in a case of a big.LITTLE SoC, passing 0 will tell you how many cores are on
// the first processor, where passing the last core number (eg., 7) will tell how many cores
// the second processor contains.
// By Robbie Ferguson // The Bald Nerd
// https://baldnerd.com/
if (is_array($argv) && isset($argv[1]) && is_numeric($argv[1])) {
$core = intval($argv[1]);
$valid = 0; // assume invalid core until we've confirmed otherwise
} else {
die('Usage: ' . $argv[0] . ' 1' . PHP_EOL);
}
$cpuinfo = file('/proc/cpuinfo');
if (is_array($cpuinfo)) {
foreach ($cpuinfo as $data) {
if (substr($data,0,9) == 'processor') {
$tmp = explode(':',$data);
$processor = trim($tmp[1]);
} elseif (substr($data,0,8) == 'CPU part') {
$tmp = explode(':',$data);
$part = trim($tmp[1]);
} elseif (substr($data,0,12) == 'CPU revision') {
$tmp = explode(':',$data);
$revision = trim($tmp[1]);
// I have the processor number, part and revision, proceed
$cores[$part . '.' . $revision][$processor] = $processor;
if ($processor == $core) {
$valid = 1;
$validproc = $part . '.' . $revision;
}
}
}
}
// this core is valid (passed by command line)
if ($valid == 1) {
echo count($cores[$validproc]); // Number of cores in the processor of the chosen core
} else {
echo 0; // no cores in the chosen processor since it doesn't exist
}
echo PHP_EOL;
?>
@@ -1,4 +1,8 @@
#!/bin/bash

# Version of cat5tv-sbctest this is based upon
c5ver="2.2"

start=`date +%s`

if [[ ! -e /usr/local/bin/nems-info ]]; then
@@ -43,6 +47,13 @@ printf "NEMS Version: " >> $tmpdir/nems-benchmark.log
ver=$(/usr/local/bin/nems-info nemsver)
echo $ver >> $tmpdir/nems-benchmark.log

echo "Using algorithms from cat5tv-sbctest v$c5ver" >> $tmpdir/nems-benchmark.log
prog=$(which 7za || which 7zr)
echo "" >> $tmpdir/nems-benchmark.log
printf "LZMA Benchmarks Provided By: " >> $tmpdir/nems-benchmark.log
$prog 2>&1 | head -n3 >> $tmpdir/nems-benchmark.log
echo "" >> $tmpdir/nems-benchmark.log

printf "Platform: " >> $tmpdir/nems-benchmark.log
platform=$(/usr/local/bin/nems-info platform-name)
echo $platform >> $tmpdir/nems-benchmark.log
@@ -71,8 +82,7 @@ echo "Number of threads: $cores" >> $tmpdir/nems-benchmark.log

cd $tmpdir

printf "Performing 7z Benchmark: " >> $tmpdir/nems-benchmark.log
prog=$(which 7za || which 7zr)
printf "Performing LZMA Benchmark: " >> $tmpdir/nems-benchmark.log
if [[ -z $prog ]]; then
apt update && apt -y install p7zip
prog=$(which 7za || which 7zr)
@@ -84,9 +94,37 @@ if [[ ! -z $prog ]]; then
"$prog" b > $tmpdir/7z.log
result7z=$(awk -F" " '/^Tot:/ {print $4}' <$tmpdir/7z.log | tr '\n' ', ' | sed 's/,$//')
echo "Done." >> $tmpdir/nems-benchmark.log
echo "7z Benchmark Result: $result7z" >> $tmpdir/nems-benchmark.log
echo "Multi-Threaded Benchmark Result: $result7z" >> $tmpdir/nems-benchmark.log
echo $result7z > /var/log/nems/benchmarks/7z-multithread


# Average Single Thread benchmark
# Get the total result from first CPU core
taskset -c 0 "$prog" b > $tmpdir/7z.log
result1=$(awk -F" " '/^Tot:/ {print $4}' <$tmpdir/7z.log | tr '\n' ', ' | sed 's/,$//')
cores1=$(/usr/local/share/nems/nems-scripts/benchmark-parsecores.sh 0)
# Get the total result from last CPU core (might be big.LITTLE, or could be same core)
lastcore=$(( $cores - 1 ))
cores2=0
if (( $lastcore > 0 )) && (( $cores1 < $cores )); then
taskset -c $lastcore "$prog" b > $tmpdir/7z.log
result2=$(awk -F" " '/^Tot:/ {print $4}' <$tmpdir/7z.log | tr '\n' ', ' | sed 's/,$//')
cores2=$(/usr/local/share/nems/nems-scripts/benchmark-parsecores.sh $lastcore)
else
result2=$result1 # Single-core processor or all cores are on same chip
fi
# Multiply our first and last result by the number of cores on that processor
# This assumes each core of the same processor will clock roughly the same
# which is not literally accurate, but gives us a reasonable approximation without
# having to benchmark each and every core.
if (( $cores2 > 0 )); then
average7z=$(( ( ($result1*$cores1) + ($result2*$cores2) ) / 2 ))
else
average7z=$(( ($result1*$cores1) ))
fi
echo "Single-Threaded Benchmark Result: $average7z" >> $tmpdir/nems-benchmark.log
echo $average7z > /var/log/nems/benchmarks/7z-singlethread

else
echo "Can't find or install p7zip. 7z benchmark skipped." >> $tmpdir/nems-benchmark.log
fi
@@ -371,7 +371,14 @@ elif [[ $COMMAND == "benchmark" ]]; then
echo 0
fi
fi
if [[ $VARIABLE == '7z' ]]; then
if [[ $VARIABLE == '7z-s' ]]; then
if [[ -f /var/log/nems/benchmarks/7z-singlethread ]]; then
cat /var/log/nems/benchmarks/7z-singlethread
else
echo 0
fi
fi
if [[ $VARIABLE == '7z-m' ]]; then
if [[ -f /var/log/nems/benchmarks/7z-multithread ]]; then
cat /var/log/nems/benchmarks/7z-multithread
else
@@ -61,7 +61,8 @@ if (file_exists('/var/log/nems/hw_model')) { // Don't run this until system is r
$benchmarks['ram'] = shell_exec('/usr/local/bin/nems-info benchmark ram');
$benchmarks['io'] = shell_exec('/usr/local/bin/nems-info benchmark io');
$benchmarks['mutex'] = shell_exec('/usr/local/bin/nems-info benchmark mutex');
$benchmarks['sevenzip'] = shell_exec('/usr/local/bin/nems-info benchmark 7z');
$benchmarks['sevenzip-singlethread'] = shell_exec('/usr/local/bin/nems-info benchmark 7z-s');
$benchmarks['sevenzip-multithread'] = shell_exec('/usr/local/bin/nems-info benchmark 7z-m');
// Put it together to send to the server
$data = array(

0 comments on commit c9f06e0

Please sign in to comment.
You can’t perform that action at this time.