File: test_threading.sh

package info (click to toggle)
vips 8.17.3-2
  • links: PTS
  • area: main
  • in suites: sid
  • size: 52,228 kB
  • sloc: ansic: 169,684; cpp: 12,156; python: 4,887; sh: 733; perl: 40; makefile: 25; javascript: 6
file content (57 lines) | stat: -rwxr-xr-x 1,306 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/sh

# set -x

. ./variables.sh 

exit_code=0
$vips im_benchmarkn || exit_code=$?
if [ $exit_code -ne 0 ]; then
	echo "im_benchmark is not available, skipping test"
	exit 0
fi

chain=1

# im_benchmark needs a labq
$vips colourspace $image $tmp/t3.v labq

for tile in 10 64 128 512; do
	# benchmark includes a dither which will vary with tile size
	$vips --vips-concurrency=1 \
		--vips-tile-width=$tile --vips-tile-height=$tile \
		im_benchmarkn $tmp/t3.v $tmp/t5.v $chain

	for cpus in 2 3 4 5 6 7 8 99; do
		echo trying cpus = $cpus, tile = $tile ...
		$vips --vips-concurrency=$cpus \
			--vips-tile-width=$tile --vips-tile-height=$tile \
			im_benchmarkn $tmp/t3.v $tmp/t7.v $chain
		$vips subtract $tmp/t5.v $tmp/t7.v $tmp/t8.v
		$vips abs $tmp/t8.v $tmp/t9.v
		max=$($vips max $tmp/t9.v)
		if [ $(echo "$max > 0" | bc) -eq 1 ]; then
			break
		fi
	done
	if [ $(echo "$max > 0" | bc) -eq 1 ]; then
		break
	fi
done

if [ $(echo "$max > 0" | bc) -eq 1 ]; then
	echo error, max == $max
	exit 1
else
	echo all benchmark threading tests passed
fi

# setting VIPS_MAX_THREADS low should force a small thread limit
echo -n "checking threadset size limit ... "
VIPS_MAX_THREADS=5 VIPS_CONCURRENCY=3 $vips copy $image x.v || exit_code=$?
if [ $exit_code -ne 0 ]; then
  echo FAILED
  exit 1
fi
echo ok