diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-04-21 17:19:52 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-04-21 17:19:52 -0700 |
commit | f7a2671901bc396ecd5578ba624c4532d6bbf4f3 (patch) | |
tree | d64e0eacb0aeef937297a05407ecd2366c82f910 /mu.arc | |
parent | 963711e4cbc1c87314f66310da2d6f89aa471907 (diff) | |
download | mu-f7a2671901bc396ecd5578ba624c4532d6bbf4f3.tar.gz |
1119 - preparing to start porting chessboard
Arc version is 15% faster (8.3s vs 9.9s for print-board test) if I use an intermediate array rather than list. I'm starting to question the whole tagged-value design, and the current tagged-value implementation was treating squares as integers in one place anyway, so its benefits for typing are not great. Might as well create a good baseline for the Arc vs C++ performance test.
Diffstat (limited to 'mu.arc')
-rw-r--r-- | mu.arc | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/mu.arc b/mu.arc index 292126b3..d95ae335 100644 --- a/mu.arc +++ b/mu.arc @@ -936,6 +936,9 @@ (if (len> caller-args.routine* idx) (list caller-args.routine*.idx t) (list nil nil)))) + rewind-inputs + (do1 nil + (= caller-arg-idx.routine* 0)) ; type and otype won't always easily compile. be careful. type (ty (caller-operands.routine* (v arg.0))) @@ -1934,6 +1937,37 @@ (result:list-address <- list-next result:list-address) ; memory leak (reply result:list-address)) +; create an array out of a list of scalar args +; only integers for now +(init-fn init-array + (default-space:space-address <- new space:literal 30:literal) + (capacity:integer <- copy 0:literal) + { begin + ; while read curr-value + (curr-value:integer exists?:boolean <- next-input) + (break-unless exists?:boolean) + (capacity:integer <- add capacity:integer 1:literal) + (loop) + } + (result:integer-array-address <- new integer-array:literal capacity:integer) + (rewind-inputs) +;? (xxx:integer <- next-input) ;? 1 +;? ($print xxx:integer) ;? 1 +;? (rewind-inputs) ;? 1 + (i:integer <- copy 0:literal) + { begin + ; while read curr-value + (done?:boolean <- greater-or-equal i:integer capacity:integer) + (break-if done?:boolean) + (curr-value:integer exists?:boolean <- next-input) + (assert exists?:boolean) + (tmp:integer-address <- index-address result:integer-array-address/deref i:integer) + (tmp:integer-address/deref <- copy curr-value:integer) + (i:integer <- add i:integer 1:literal) + (loop) + } + (reply result:integer-array-address)) + (init-fn list-length (default-space:space-address <- new space:literal 30:literal) (curr:list-address <- next-input) |