Skip to content

Instantly share code, notes, and snippets.

@bogdando
Last active February 1, 2019 10:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bogdando/9b6dc40c06aa3b8cc70b0cee120aae84 to your computer and use it in GitHub Desktop.
Save bogdando/9b6dc40c06aa3b8cc70b0cee120aae84 to your computer and use it in GitHub Desktop.
Comparing the time it takes to launch containers concurrently for docker and podman runtimes
#!/bin/bash
set -e
containers_total=${1:-100}
containers_concur=${2:-10}
container_image=${3:-docker.io/library/busybox}
podman pull $container_image
docker pull $container_image
rm -f bench-jobs.txt
podman rm -f $(sudo podman ps -qa --filter name=cbench)||:
docker rm -f $(sudo docker ps -qa --filter name=cbench)||:
for i in $(seq 1 $containers_total); do
cmd="run -d --name cbench$i -v /sys/fs/cgroup:/sys/fs/cgroup -m 100M --cpus=1 --cpu-shares=100 $container_image sleep $(( containers_concur * 2 ))"
echo "$cmd" >> bench-jobs.txt
done
set -x
exec 3>&1
{ time cat bench-jobs.txt | xargs -r -n1 -P $containers_concur -I{} bash -c "echo docker {}; { time docker {} 1>&3; } 2>&1" 1>&3; } 2>&1
{ time cat bench-jobs.txt | xargs -r -n1 -P $containers_concur -I{} bash -c "echo podman {}; { time podman {} 1>&3; } 2>&1" 1>&3; } 2>&1
exec 3>&-
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment