On Aug 25, 2008, at 12:50 PM, Tobia Conforto wrote:
Matt Welland wrote:
the tactic of loading lots of data into a hierarchy of hash arrays
and then extracting the needed pieces in a myriad of ways,
sometimes on the fly in a meeting with management nervously looking
on :-) has been
Elf wrote:
(define a
(alist-hash-table
(let loop ((i 0))
(if (fx= 25 i)
'()
(cons (cons (random 50)
(random 50))
(loop (fx+ 1 i)
=))
for an improvement in time (surprisingly), use
(define a
i got almost the same time as with my previous (incorrect) method by using a
single hash table and an alist instead of a hash for the inner structure.
memory usage isnt so good though. :(
using a sparse multiple-alist structure seems to work nicely in small space
and good time. i can post
On Mon, 25 Aug 2008, Tobia Conforto wrote:
Elf wrote:
(define a
(alist-hash-table
(let loop ((i 0))
(if (fx= 25 i)
'()
(cons (cons (random 50)
(random 50))
(loop (fx+ 1 i)
=))
for an improvement in
Matt Welland wrote:
the tactic of loading lots of data into a hierarchy of hash arrays
and then extracting the needed pieces in a myriad of ways, sometimes
on the fly in a meeting with management nervously looking on :-) has
been tremendously useful for me. I for one am hoping that there
Hi!
This should perform much better and more closely
resembles what you are trying to achieve.
Note that Perl's data structures are bummed to absurd
dimensions. We don't want that.
cheers,
felix
--
(use extras)
(define a (make-hash-table equal?))
(print filling ...)
(do ((i 0 (add1 i)))
my solution :) its faster (at least on chicken 3.3.something).
timing on this box put this at just under 8s.
-elf
---
(use extras)
(print filling ...)
(define a
(alist-hash-table
(let loop ((i 0))
(if (fx= 25 i)
'()
(cons (cons
for an improvement in time (surprisingly), use
(define a
(alist-hash-table
(let loop ((i 0)
(r '()))
(if (fx= 25 i)
r
(loop (fx+ 1 i)
(cons (cons (random 50) (random 50)) r
i've been testing various solutions, which ill be happy to post if interested.
all of them involve alist-hash-table. so far, the fastest solution, on
average, has been list-tabluate to generate the list. (map! was a close
contender, though.) the solution with the least GCs, on average, uses
one final note:
the time and memory usage for the list-tabulate, map!, and unfold solutions,
on my box, are approximately 0.4s slower than perl, with slightly better
memory usage stats (in chicken, that is).
hope this helps.
-elf
___
As a comparison, Felix's solution performs equivalently to my alist
example when compiled, but runs much faster from the REPL. It also
uses 9MB instead of 13MB. It's also simpler.
On Sun, Aug 24, 2008 at 4:06 AM, felix winkelmann [EMAIL PROTECTED] wrote:
This should perform much better and
Note that your solution effects a mapping of x - y, not from x - y
- #t. That gets the job accomplished correctly, but doesn't reflect
the original Perl code. For a fair comparison, you have to change the
perl code to match, and then it runs in 1/3 of the memory and 1/2 the
time of the original
Wow, thanks. That cut my run time in half to aprox 8..4 seconds. I'm
using chicken 2.74 on this machine. I've tried 3.3 at a different
machine but not seen much difference.
Note that changing to non-hierarchical hashes breaks a lot of my
existing code and is not exactly apples to apples with the
My attempts all use gigs of memory and run 10x as long.
#!/usr/bin/perl -w
print Filling the array with 25 entries.\n;
foreach $n (0 .. 25) {
$x = int(rand(50));
$y = int(rand(50));
$a{$x}{$y}=1;
}
print Reading from the arrary 1 times\n;
$hits=0;
foreach $n (0 ..
Matt Welland scripsit:
My attempts all use gigs of memory and run 10x as long.
So show us the problematic code, then.
--
When I'm stuck in something boring John Cowan
where reading would be impossible or(who loves Asimov too)
rude, I often set up math problems for
Sorry for the overly brief problem statement. This is the two deep
sparse array code I threw together. BTW, in the test code I am using
numbers as the keys out of lazyness. The real code may use strings and
or numbers. I'm using chicken 2.740 and 3.3.0 if it matters.
I guess my question really
16 matches
Mail list logo