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

2010 Homework No. 3 - findsuss

Name: Anonymous 2010-01-15 22:56

Write a program in the language of your choice that takes a string and inputs "SUSSMAN" for every time those characters appear. In case I'm not being clear, that means output "SUSSMAN" for every 3 's's and 1 'u', 'm', 'a', and 'n' in the string. Inputting "ssssumanssssssssssuman", for example, would print "SUSSMAN" twice. "ssuman", however, would print nothing.

I've written an inelegant solution in C, which I'll post in a second. It tends to crash after execution, however, and I cannot for the life of me figure out what I'm doing wrong. It does everything it's supposed to but refuses to terminate politely. Even stranger, it only happens when there is enough characters for two or more sussmen. I guess the problem is in the susscount loop, but I can't figure out where. Mind giving me a hand, /prog/?

Name: EXPERT PROFILER 2010-01-16 17:47

HASKAL RESULTS ARE OUT
My array-based code (>>10) wins for now. Extra points to >>38 who gets very close using elegant arrows.

Everything run with a 91KB text file containing "sussman sussman"... repeated until the file was big enough.
Compiled with ghc --make -02 -auto-all -fforce-recomp -prof findsuss.hs and ran with findsuss findt +RTS -p -sstderr -hd > findtout (on Windows, so the > pipes the output to a file in order to save my emacs console from death). I have the memory allocation profiles (in PDF) for all posts, will post if there's interest.


Run time in seconds (Core 2 Duo laptop)
>>10   >>38   >>35    >>56   >>55  
0.30   0.50   32.07   32.68  44.93


>>35
  22,532,708,420 bytes allocated in the heap
   2,509,842,544 bytes copied during GC
       1,849,172 bytes maximum residency (1725 sample(s))
          86,004 bytes maximum slop
               6 MB total memory in use (0 MB lost due to fragmentation)

  Generation 0: 41396 collections,     0 parallel,  2.61s,  2.65s elapsed
  Generation 1:  1725 collections,     0 parallel,  2.31s,  2.08s elapsed

  INIT  time    0.00s  (  0.00s elapsed)
  MUT   time   26.79s  ( 27.46s elapsed)
  GC    time    4.91s  (  4.73s elapsed)
  RP    time    0.00s  (  0.00s elapsed)
  PROF  time    0.37s  (  0.36s elapsed)
  EXIT  time    0.00s  (  0.00s elapsed)
  Total time   32.07s  ( 32.55s elapsed)

  %GC time      15.3%  (14.5% elapsed)

  Alloc rate    841,231,738 bytes per MUT second

  Productivity  83.5% of total user, 82.3% of total elapsed

>>55
  22,534,919,924 bytes allocated in the heap
   1,712,117,048 bytes copied during GC
         243,460 bytes maximum residency (1639 sample(s))
          39,136 bytes maximum slop
               2 MB total memory in use (0 MB lost due to fragmentation)

  Generation 0: 41552 collections,     0 parallel,  2.62s,  2.97s elapsed
  Generation 1:  1639 collections,     0 parallel,  0.36s,  0.49s elapsed

  INIT  time    0.02s  (  0.00s elapsed)
  MUT   time   40.92s  ( 41.43s elapsed)
  GC    time    2.98s  (  3.46s elapsed)
  RP    time    0.00s  (  0.00s elapsed)
  PROF  time    0.02s  (  0.04s elapsed)
  EXIT  time    0.00s  (  0.00s elapsed)
  Total time   43.93s  ( 44.93s elapsed)

  %GC time       6.8%  (7.7% elapsed)

  Alloc rate    550,509,504 bytes per MUT second

  Productivity  93.1% of total user, 91.1% of total elapsed

>>38
     109,663,904 bytes allocated in the heap
      77,659,004 bytes copied during GC
       4,606,460 bytes maximum residency (19 sample(s))
          29,116 bytes maximum slop
              13 MB total memory in use (0 MB lost due to fragmentation)

  Generation 0:   191 collections,     0 parallel,  0.19s,  0.15s elapsed
  Generation 1:    19 collections,     0 parallel,  0.14s,  0.11s elapsed

  INIT  time    0.00s  (  0.00s elapsed)
  MUT   time    0.16s  (  0.18s elapsed)
  GC    time    0.33s  (  0.26s elapsed)
  RP    time    0.00s  (  0.00s elapsed)
  PROF  time    0.02s  (  0.00s elapsed)
  EXIT  time    0.00s  (  0.00s elapsed)
  Total time    0.50s  (  0.44s elapsed)

  %GC time      65.6%  (58.1% elapsed)

  Alloc rate    702,973,743 bytes per MUT second

  Productivity  31.2% of total user, 35.3% of total elapsed

>>10
      31,085,184 bytes allocated in the heap
       7,515,104 bytes copied during GC
       4,689,640 bytes maximum residency (3 sample(s))
         842,360 bytes maximum slop
              12 MB total memory in use (0 MB lost due to fragmentation)

  Generation 0:    43 collections,     0 parallel,  0.23s,  0.23s elapsed
  Generation 1:     3 collections,     0 parallel,  0.02s,  0.03s elapsed

  INIT  time    0.00s  (  0.00s elapsed)
  MUT   time    0.05s  (  0.07s elapsed)
  GC    time    0.25s  (  0.26s elapsed)
  RP    time    0.00s  (  0.00s elapsed)
  PROF  time    0.00s  (  0.00s elapsed)
  EXIT  time    0.00s  (  0.00s elapsed)
  Total time    0.30s  (  0.34s elapsed)

  %GC time      84.2%  (77.8% elapsed)

  Alloc rate    664,199,141 bytes per MUT second

  Productivity  15.8% of total user, 13.8% of total elapsed

>>56
  22,530,904,044 bytes allocated in the heap
   2,630,688,952 bytes copied during GC
       1,851,628 bytes maximum residency (1709 sample(s))
          87,692 bytes maximum slop
               6 MB total memory in use (0 MB lost due to fragmentation)

  Generation 0: 41401 collections,     0 parallel,  3.03s,  2.91s elapsed
  Generation 1:  1709 collections,     0 parallel,  1.68s,  1.93s elapsed

  INIT  time    0.00s  (  0.00s elapsed)
  MUT   time   27.66s  ( 27.57s elapsed)
  GC    time    4.71s  (  4.84s elapsed)
  RP    time    0.00s  (  0.00s elapsed)
  PROF  time    0.31s  (  0.38s elapsed)
  EXIT  time    0.00s  (  0.00s elapsed)
  Total time   32.68s  ( 32.79s elapsed)

  %GC time      14.4%  (14.8% elapsed)

  Alloc rate    814,596,463 bytes per MUT second

  Productivity  84.6% of total user, 84.3% of total elapsed

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