Coffeehouse Thread

7 posts

Perf Wiki on Channel 9

Back to Forum: Coffeehouse
  • User profile image
    Charles

    Rico Mariani has created a perf wiki on Channel 9!

    This is the place to get all the info you could want on how to write highly performant code in the memory managed, object oriented world.

    Thanks Rico!

  • User profile image
    Dr. Shim

    Thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you, thank you!

    Very thankful,
    Dr. Shim

    (Did I mention I was thankful?)

  • User profile image
    LarryL

    Good work my man!

    I've been hoping for something like this -- good tips under one roof.

    Thanks!

  • User profile image
    ricom
  • User profile image
    geekling

    I've got a question for Rico about one of his performance quizzes, if he's still watching.

    I've got this code that replicates (I think) the Rad Parser of
    "Performance Quiz #3" in which it takes 1.092s to parse the 2500 line text file.

    However, when I use this code, its equivilent in Boo (I think!),
    [code]
    import System
    import System.IO

    start = DateTime.Now
    stream = StreamReader("""C:\temp\quiz.txt""")
    line = ""
    delims = (' '[0], '\t'[0])
    sum = 0

    while (line = stream.ReadLine()):
        fields = line.Split(delims)
        for field in fields:
            sum += int.Parse(field)
           
    print "The total number of the ints is ${sum}"
    print "This took ${DateTime.Now - start}"
    [/code]

    I get this output:

    [code]
    The total number of the ints is 766085000
    This took 00:00:00.0300432
    [/code]

    The completion time is variable, of course, but it never goes beyond 0.4 milliseconds.

    Since C# and Boo are relatively the same, performance wise, why is my version so much faster than yours? Am I measuring the elapsed time the wrong way, or did I neglect a function call or something?

  • User profile image
    geekling

    And, just for comparison, the verbatim (copied and pasted) "Classic Parser" results, determing the run-time in the same way as the Boo sample, which was basically DateTime math.

    "The total of the ints is: 766,085,000
    Runtime: 00:00:00.0100144"

    The difference is not so large. Why for, dah?

  • User profile image
    ricom

    When I did the timing I timed the entire run from start to exit of the program so that includes all the time to load the JIT and to read the metadata necessary for jitting.  If you put the measurements in the program the you don't count (some) of the jitting time.  I don't know how your language converts to IL for jitting.  Maybe it all looks like one function?

    In this case, the RAD parser uses a lot more classes so that's probably a good bit of the code. The funny thing is that I thought that would give it more of an edge but in retrospect that's not likely true at all.

    In any case, the time analysis was very rough.  Mostly I wanted to talk about space, hence the space details.

    I guess the other thing is, it seems to be showing a 3x difference in your measurements, is that about right?  Subtracting out the jit time that might be just about right.  And of course have different machines with different cache (and hence gen0) sizes.  All of that matters too...

    Did I mention that my articles are only approximately correct? Smiley

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.