Merge pull request #7376 from GabyCT/topic/addcray

metrics: Add C-Ray performance test
This commit is contained in:
GabyCT
2023-07-20 14:37:53 -06:00
committed by GitHub
4 changed files with 94 additions and 0 deletions

View File

@@ -83,6 +83,12 @@ convolutional models.
For further details see the [machine learning tests documentation](machine_learning).
### `CPU`
Tests related with `CPU` performance.
For further details see the [`cpu` tests documentation](cpu).
## Saving Results
In order to ensure continuity, and thus testing and historical tracking of results,

View File

@@ -0,0 +1,9 @@
# Kata Containers C-Ray Metrics
This is a test of C-Ray which is a simple raytracer designed to test the floating-point CPU performance.
## Running the C-Ray test
Individual test can be run by hand, for example:
```
$ cd metrics/disk/c-ray $ ./cray.sh
```

View File

@@ -0,0 +1,26 @@
# Copyright (c) 2023 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
# Usage: FROM [image name]
FROM ubuntu:20.04
# Version of the Dockerfile
LABEL DOCKERFILE_VERSION="1.0"
ENV DEBIAN_FRONTEND=noninteractive
# URL for c-ray benchmark
ENV CRAY_URL "http://www.phoronix-test-suite.com/benchmark-files/c-ray-1.1.tar.gz"
RUN apt-get update && \
apt-get install -y --no-install-recommends build-essential gcc curl && \
apt-get remove -y unattended-upgrades && \
curl -OkL "${CRAY_URL}" && \
tar -zxvf c-ray-1.1.tar.gz && \
cd c-ray-1.1 && \
cc -o c-ray-mt c-ray-mt.c -lm -lpthread && \
make && \
make install
CMD ["/bin/bash"]

53
tests/metrics/cpu/c-ray/cray.sh Executable file
View File

@@ -0,0 +1,53 @@
#!/bin/bash
#
# Copyright (c) 2023 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
set -e
# General env
SCRIPT_PATH=$(dirname "$(readlink -f "$0")")
source "${SCRIPT_PATH}/../../lib/common.bash"
TEST_NAME="cray"
IMAGE="docker.io/library/cray:latest"
DOCKERFILE="${SCRIPT_PATH}/Dockerfile"
CMD="cd c-ray-1.1 && ./c-ray-mt -t 32 -s 1024x768 -r 8 -i sphfract -o output.ppm 2>&1 | tee -a output.txt && cat output.txt"
cray_file=$(mktemp crayresults.XXXXXXXXXX)
function remove_tmp_file() {
rm -rf "${cray_file}"
}
trap remove_tmp_file EXIT
function main() {
# Check tools/commands dependencies
cmds=("awk" "docker")
init_env
check_cmds "${cmds[@]}"
check_ctr_images "$IMAGE" "$DOCKERFILE"
sudo -E "${CTR_EXE}" run --rm --runtime="${CTR_RUNTIME}" "${IMAGE}" test sh -c "${CMD}" > "${cray_file}"
metrics_json_init
results=$(cat "${cray_file}" | grep seconds | awk '{print $3}' | head -n 1)
metrics_json_start_array
local json="$(cat << EOF
{
"rendering": {
"Result": ${results},
"Units": "s"
}
}
EOF
)"
metrics_json_add_array_element "$json"
metrics_json_end_array "Results"
metrics_json_save
clean_env_ctr
}
main "$@"