

# Generate statistic graph
plots:
	for I in `cd Students ; echo *` ; \
		do echo ; echo $$I ;  main.py $$I plot ; \
	done

regtest: # Use port 34000
	Scripts/regtest.py nowait

load_simulator: # Use port 34001
	ulimit -s 512 ; \
	TIME_SLICE=300 ; \
	for NR_STUDENTS in 50 100 200 300 400 ; \
	do \
	Scripts/load_simulator.py \
		$$NR_STUDENTS \
		$$TIME_SLICE \
		Students/L2unix2005s2/Logs \
		Questions/unix \
		1 0 34001 load_simulator \
		 >Stats/load_simulator.$$NR_STUDENTS.$$TIME_SLICE.unix ; \
	done

profiling: # Use port 34002
	ulimit -s 512 ; \
	TIME_SLICE=300 ; \
	NR_STUDENTS=50 ; \
	QUESTIONS=unix ; \
	Scripts/load_simulator.py \
		$$NR_STUDENTS \
		$$TIME_SLICE \
		Students/L2unix2005s2/Logs \
		Questions/$$QUESTIONS \
		100 `expr $$NR_STUDENTS '*' 1` 34002 profiling ; \
	awk '/primitive calls/ { T=1 ; } T == 1 { print $$0 ; }' \
		<Students/profiling/logs \
		>Stats/profiling.$$NR_STUDENTS.$$QUESTIONS

simulator_plot:
	# Scripts/simulator_plot 0.fixed_ttl
	Scripts/simulator_plot 1.variable_ttl
	Scripts/simulator_plot 2.caches_answerable_action

clean:
	find . -name 'xxx*' -o -name '*~' -o -name '*.pyc' \
		-o -name 'nohup.out' | xargs rm -f
	-rm -r Students/profiling Students/regtest

figures:
	for I in HTML Questions/*/HTML ; do ( cd $$I ; $(MAKE) ) ; done

stat:
	@echo 'Python lines Quenlig : ' `cat *.py | wc -l`
	@echo 'Python lines Unix    : ' `cat Questions/unix/*.py | wc -l`
	@echo 'Python lines Python  : ' `cat Questions/python/*.py | wc -l`
	@echo 'Python lines regtest : ' `cat Scripts/regtest.py | wc -l`
	@echo 'CSS lines            : ' `cat HTML/*.css | wc -l`
	@echo 'Doc HTML             : ' `wc -l <Welcome.html`

MEDIA=/usbmem
tar:clean
	A=$$(basename $$(pwd)) ; \
	echo 'real_names = {}' >real_names.py ; \
	cd .. ; \
	tar --exclude='Students' \
	    --exclude='*.pyc' \
	    --exclude='PyChart*' \
            -cvf - $$A | \
	gzip >~/public_html/QUENLIG/$$A.tar.gz ; \
	cd ~/public_html/QUENLIG ; ls -lsh ; \
	mkdir /tmp/XXX-$$A ; cd /tmp/XXX-$$A ; \
	zcat ~/public_html/QUENLIG/$$A.tar.gz | tar -xvf - ; \
	cd $$A ; \
	make regtest ; \
	cd ; \
	rm -r /tmp/XXX-$$A
