[erlang-questions] Generating Primes and the O'Neill paper

Angel Alvarez <>
Thu Dec 17 00:32:06 CET 2009


ive changed the code to use your last assertion.

Im blindly running the code up to 1000000 just for fun but the top output seems confusing for me.

beam process has 16m on the SWAP column but overall swap usage is only 96k, 

so whats  really  SWAP means?



top - 00:23:27 up  7:18,  7 users,  load average: 1.11, 0.77, 0.46
Tasks: 188 total,   3 running, 185 sleeping,   0 stopped,   0 zombie
Cpu0  : 15.1%us,  1.6%sy,  0.1%ni, 80.9%id,  2.0%wa,  0.1%hi,  0.2%si,  0.0%st
Mem:   1026752k total,   915292k used,   111460k free,    55128k buffers
Swap:  2104504k total,       96k used,  2104408k free,   409480k cached

  PID USER      PR  NI  VIRT  RES  SHR CODE DATA S SWAP %CPU %MEM    TIME+    TIME COMMAND
30829 sinosuke  25   0 58352  40m 1968 1488  53m R  16m 97.0  4.1   4:29.41   4:29 beam
30883 root      15   0  2316 1156  840   84  472 R 1160  0.7  0.1   0:03.11   0:03 top

/angel

El Jueves, 17 de Diciembre de 2009 Roberto Ostinelli escribió:
> >> why not simply:
> >>
> >> compare(X,Y) when X > Y -> greater;
> >> compare(X,Y) when X < Y -> smaller;
> >> compare(X,Y) -> equal.
> >
> >
> > Thanks!!  I forget it was erlang!!
> >
> >
> > the last one can be
> > compare(X,X) -> equal.?
> 
> sure.
> 
> though, if you are optimizing, i suspect compare(X,Y) might have one
> matching call less to go [since it's a generic fallback], so probably
> the fastest version would be something like
> 
> compare(X,Y) when X > Y -> greater;
> compare(X,Y) when X < Y -> smaller;
> compare(_, _) -> equal.
> 
> r.
> 



-- 
Agua para todo? No, Agua para Todos.
->>-----------------------------------------------
    Clist UAH a.k.a Angel
---------------------------------[www.uah.es]-<<--

Hoy no has conseguido la iluminación divina. No importa mañána será otro día...


More information about the erlang-questions mailing list