Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

RE: How DO those monks do it?

by runrig (Abbot)
on Oct 17, 2000 at 21:21 UTC ( #37193=note: print w/replies, xml ) Need Help??


in reply to How DO those monks do it?

I STILL constantly refer to 'perldoc -f <perlfunction>'and find it invaluable. Just yesterday I had to look up the arguments for index() and their order. It was a happy day when I found out about the '-f' option and didn't have to search through 'perlfunc' anymore. I wish you could do that with all the perl modules too.

At the more general 'how do I do something' sort of level, I've found the perlfaqs very handy. When I needed to fork(), there were examples in perlipc. Since I've scanned all the perldocs, I have a vague idea of most everything in there, and if I can't find it in there, then I'll go to a book (I have the Cookbook, and at my latest work we have all the other books also). I just wish I had all the animal books to refer to when I was just learning perl, all there was was one crappy book at work, so the perldocs were usually more helpful. (Why didn't I go get'em myself? I dunno...).

I try to write code in small bits that can be tested separately whenever possible. I hate it when someone modifies a large application and breaks it when a small test case could have avoided disaster (which is becoming my latest justified pet peeve). I'll benchmark if I think its worthwhile and/or if I have time and/or if I'm just curious enough. Going back to that 'index' function, I was wondering how much faster using 'index' was versus a regex, because a co-worker wrote a split using a regex, and index() could have been used instead. It was something like: my ($str1, $str2, $str3, $str4) = /(.*)<tag1>(.*)<tag2>(.*)<tag3>(.*)/; I was fairly certain that using index would be faster, but not sure by how much. Even the regex could have been sped up by adding '?' after the '*' in all but the last group. For the curious, on 500 iterations, using index benchmarked for me at ~0.1 seconds, the bad regex at ~6 seconds, the slightly better regex at ~3 seconds. So in 500 executions of this script, we can save 5-6 seconds, which may or may not be worthwhile in the big picture, but at least my curiosity is satisfied.
Oh well, I don't know if that helps any or not, but Good Luck to you.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://37193]
help
Chatterbox?
[ambrus]: in the loop, and I'm not sure if that's ok for AnyEvent. Also, it's not clear if a Timer or File object you free really is garbage collected, i.e. that Prima doesn't keep some references to it, but I hope so.
[Corion]: choroba: No, I don't remember that story, but yes, it matches my experience ;))
[ambrus]: Hopefull the object isn't kept alive, the events are processed immediately, but you'd have to read a lot of source code to be sure about that.
[Corion]: ambrus: I think both of AnyEvent and Prima are pretty tight in their memory management because they both are cooperative multitasking and (I think) both use the Perl memory management for managing things
[Corion]: ambrus: And for Windows, I don't think that Prima knows if there still are messages queued for an object (in the Windows message loop). Finding that out would take lots of effort for little gain
[ambrus]: And even if this works, I'm still not sure you can't get double timeouts from a Timer.
[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?

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













    Results (150 votes). Check out past polls.