mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-06 06:48:48 +00:00
Performance test
This commit is contained in:
parent
9ff649e563
commit
669a4288d7
2 changed files with 41 additions and 0 deletions
14
performance/Makefile
Normal file
14
performance/Makefile
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
TESTS=$(sort $(basename $(wildcard *.lama)))
|
||||
|
||||
LAMAC=../src/lamac
|
||||
|
||||
.PHONY: check $(TESTS)
|
||||
|
||||
check: $(TESTS)
|
||||
|
||||
$(TESTS): %: %.lama
|
||||
@echo $@
|
||||
LAMA=../runtime $(LAMAC) $< && `which time` -f "$@\t%U" ./$@
|
||||
|
||||
clean:
|
||||
$(RM) test*.log *.s *~ $(TESTS) *.i
|
||||
27
performance/Sort.lama
Normal file
27
performance/Sort.lama
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
fun bubbleSort (l) {
|
||||
fun inner (l) {
|
||||
case l of
|
||||
x : z@(y : tl) ->
|
||||
if compare (x, y) > 0
|
||||
then [true, y : inner (x : tl) [1]]
|
||||
else case inner (z) of [f, z] -> [f, x : z] esac
|
||||
fi
|
||||
| _ -> [false, l]
|
||||
esac
|
||||
}
|
||||
|
||||
fun rec (l) {
|
||||
case inner (l) of
|
||||
[true , l] -> rec (l)
|
||||
| [false, l] -> l
|
||||
esac
|
||||
}
|
||||
|
||||
rec (l)
|
||||
}
|
||||
|
||||
fun generate (n) {
|
||||
if n then n : generate (n-1) else {} fi
|
||||
}
|
||||
|
||||
bubbleSort (generate (1000))
|
||||
Loading…
Add table
Add a link
Reference in a new issue