Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: Re: Printing a hash in a specific order?

by Limbic~Region (Chancellor)
on Mar 15, 2003 at 15:15 UTC ( #243297=note: print w/replies, xml ) Need Help??

in reply to Re: Printing a hash in a specific order?
in thread Printing a hash in a specific order?

Thank you very much! I have to look under the hood of this module as I think I have two problems that may make using it a little less than straight forward.

  • The object may change over time so I would know how to order keys that haven't been created yet.
  • If it is truly forcing the order and not performing some other kind of magic, than it is going to hurt performance.

    In reference to point one, I could always just create a place holder for all possible keys, but I am not sure I want to do that since some parameters can exist with empty string as the value and I do not want to accidently create a parameter in a record that didn't previously exist. As far as point two. I have about 150,000 records in in the database - I wouldn't mind adding some overhead for ease of use as long as it doesn't add an extra hour to processing time.

    Thanks again - I will definately check out this module.
    Cheers - L~R

    • Comment on Re: Re: Printing a hash in a specific order?
  • Replies are listed 'Best First'.
    Re: Re: Re: Printing a hash in a specific order?
    by artist (Parson) on Mar 15, 2003 at 15:44 UTC
      Hi L~R,
      You can input your data in benchmarking here.

      My benchmark, comparing 200,00 records and each record contain a 50 fields containing small numeric data as key and value, gives the results:

      Benchmark: timing 200000 iterations of with_tie, without_tie...
        with_tie: 98 wallclock secs (96.22 usr +  0.00 sys = 96.22 CPU) @ 2078.61/s (n=200000)
      without_tie: 14 wallclock secs (13.25 usr +  0.00 sys = 13.25 CPU) @ 15094.34/s (n=200000)
                     Rate    with_tie without_tie
      with_tie     2079/s          --        -86%
      without_tie 15094/s        626%          --
      And the code is

      use Benchmark qw(cmpthese); use strict; use Tie::IxHash; sub with_tie { tie my %menu, 'Tie::IxHash'; foreach (1..50){$menu{$_} = $_; } } sub without_tie{ my %menu; foreach (1..50){$menu{$_} = $_;} } cmpthese(200000, { with_tie => \&with_tie, without_tie => \&without_tie });

    Log In?

    What's my password?
    Create A New User
    Node Status?
    node history
    Node Type: note [id://243297]
    [ambrus]: Corion: well Prima::Object says something like that the cleanup method will send an onDestory message and that you can't get more messages after cleanup, or something.
    [Corion]: ambrus: Yeah - I don't think the deep source dive will be necessary if things are implemented as simple as they could be :)) And hopefully I won't need (more) timely object destruction. I can update the screen at 60Hz and hopefully even do HTTP ...
    [Corion]: ... transfers in the background. Now that I think about it, this maybe even means that I can run the OpenGL filters on Youtube input :)
    [ambrus]: Corion: I mentioned that the unix event loop of Prima always wakes up at least once every 0.2 seconds. Have you found out whether the win32 event loop of Prima does that too?
    [Corion]: ambrus: Hmm - I would assume that the onDestroy message is sent from the destructor and doesn't go through the messageloop, but maybe it is sent when a window gets destroyed but all components are still alive...
    [ambrus]: Corion: partly deep source dive, partly just conservative coding even if it adds an overhead.
    [Corion]: ambrus: Hmm - no, I haven't looked at wakeup intervals ... I wonder why it should want to wakeup periodically because it gets a lot of messages from the Windows message loop (on Windows obviously)
    [ambrus]: (Alternately a deep source dive and then rewrite that event loop to make it better, and then as a bonus you get an idle method.)
    [ambrus]: The 0.2 seconds wakeup is likely a workaround for some bug, but I can't guess what bug that is.
    [ambrus]: It's been there since Prima 1.00 iirc

    How do I use this? | Other CB clients
    Other Users?
    Others chanting in the Monastery: (7)
    As of 2016-12-09 10:29 GMT
    Find Nodes?
      Voting Booth?
      On a regular basis, I'm most likely to spy upon:

      Results (150 votes). Check out past polls.