Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Homework

Name: Anonymous 2009-04-26 14:19

Output "Sussman" as many times as possible in one second, using Ruby.

Name: Anonymous 2009-04-26 14:23

>>1
Depending how you interpret the parentheses on the scope of "as many times as possible", you are asking us to output sussman the exact 100% optimal number of times for a given CPU in one second, using ruby. Read: not possible.

Name: Anonymous 2009-04-26 14:24

19208 sussmans per second.
How do I run a script that sussmans and kill it after one second.
?

Name: Anonymous 2009-04-26 14:24

loop { Thread.new { loop { puts "Sussman" } } }

Name: Anonymous 2009-04-26 14:25

But that's impossible, since it takes more than one second to output text.

HIBT?

Name: Anonymous 2009-04-26 14:30

>>3
add TMOUT=1 to your .profile

Name: Anonymous 2009-04-26 14:31

>>5
Sorry, I meant to add that it's impossible in Ruby.

Name: Anonymous 2009-04-26 14:33

>>4
I doubt this will help the performance at all. How fast the program can loop is not the bottle neck here, but how fast the output stream can be written to and flushed.

Name: Anonymous 2009-04-26 15:02

>>8
Indeed, Ruby is written in C which leaves how threaded writing to stdout should be handled to the implementation. Most implementations are thread safe on FILE* writing, so I presume they will just mutex the buffer, and infact you may even get worse performance.

Name: Anonymous 2009-04-27 0:36

>>4
Single quotes for faster code.

Name: Anonymous 2009-04-27 0:40

s="Sussman\n"*1000;puts s while 0

Name: Anonymous 2009-04-27 1:29

real languages > toy languages
#include <string.h>

#include <unistd.h>
#include <sys/time.h>

int main(void)
{ for
  ( setitimer
    ( 0,
      &( struct itimerval )
      { .it_interval = ( struct timeval ){ .tv_sec = 1, .tv_usec = 0 },
        .it_value = ( struct timeval ){ .tv_sec = 1, .tv_usec = 0 }},
      NULL );;
    write(0, "Sussman", 8)); }

Name: Anonymous 2009-04-27 1:48

>>12
alarm(1) works too =P

Name: Anonymous 2009-04-27 1:52

>>13
This interface is made obsolete by setitimer(2).

Name: Anonymous 2009-04-27 1:54

>>14
Oh please, they're never going to remove that interface. (Well, Theo might, but he's mentally unstable.)

Name: Anonymous 2009-04-27 2:02

remove it, no.
replace it with a horribly slow and inefficient wrapper around setitimer, definitely.

Name: Anonymous 2009-04-27 2:18

Name: Anonymous 2009-04-27 3:31

this would depend highly on the terminal and where you output it, filesystem optimizations and or socket buffers

Name: Anonymous 2009-04-28 9:05

christopher@chrislaptop$ time ruby -e "puts 'sussman'"
sussman
     3.65 real         1.24 user         1.39 sys

Name: Anonymous 2009-04-28 10:24

$ time ghc -e 'putStrLn "sussman"'
*** Exception: stack overflow
real    0m3.318s
user    0m2.764s
sys    0m0.440s

Name: STACK_OVERFLOW_MEME_FAN 2009-04-28 10:27

>>20
I approve of this post

Name: Anonymous 2009-04-28 10:50

>>21
All of your "memes" are disgusting.

Name: Anonymous 2009-04-28 11:02

>>20
Yeah, I kinda like this meme. Weird, sinc

Name: Anonymous 2011-06-16 6:57

RETARD THREAD IS RETARD

Name: Anonymous 2012-10-26 13:45

how do I codetags?


[C]
int main(){
printf("se a shuit");


}
[/C]

Don't change these.
Name: Email:
Entire Thread Thread List