Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Why so slow when using Perl/Tk?

by ww (Archbishop)
on Jul 28, 2009 at 22:28 UTC ( [id://784059]=note: print w/replies, xml ) Need Help??


in reply to Why so slow when using Perl/Tk?

Knowing even less about Tk than you profess to know, this is not an answer to the question asked, but rather a distinctly non-rhetorical question in reply:

Why are you using Tk merely to create a button?

It seems likely to me that executing this script is not significantly less demanding (of the ultimate user) than it would be to execute a non-GUI script from the command line.

Granted, when you write the code to populate your hashes (rather than hardcoding them), your CLI script will likely need argument(s) [source file(s) and output file] but if the Monks who can answer your actual question conclude that the issue is in some- or large-part the extra overhead of Tk, you're faced with a choice: "to take a hit in performance in exchange for the simple interface" or to offer the user(s) a usage prompt or training.

Replies are listed 'Best First'.
Re^2: Why so slow when using Perl/Tk?
by RAS230 (Acolyte) on Jul 28, 2009 at 22:54 UTC
    No, the actual interface isn't just a button. :) If that were the case I'd agree that it wouldn't be worth the trouble. In general I'd rather just run things from the command line which is why this is only my 2nd attempt at using perl/tk. :)

    In the actual script none of the data is hard coded. All the input gets put into the interface (text boxes, drop downs etc) and then that data is processed and used to populate the hashes/html table/etc.

    None of that extra stuff was a major contributor to the speed problem however, so I kept the perl/tk stuff as simple as possible in my example.

    If the speed is all just overhead and there's nothing for it than I'll have to start looking at other options. The problem seems to be output related more than anything. It's strange, but I've noticed that if I write the output to a plain text file and just open it with notepad it does seem a bit faster. I may have to settle with that, but I'd lose a lot in the formatting/spacing department.

      Eminently reasonable. Seems sensible!

      But your distinction between a plain text file and the .html output of your OP puzzles me again, as any difference should be negligible: the .html source is, to all intents and purposes as far as writing the file is concerned, a "plain text file."

      Or does your actual script open a browser after writing the output? That, of course, would add a bit more overhead. In that case, you cantrim the rendering time by assigning width to table and the ten tds.

      In any case, it may be useful to profile your actual script: see http://search.cpan.org/~timb/Devel-NYTProf-2.10/lib/Devel/NYTProf.pm.

      OTOH, it may be even more useful to await better answers from Tk gurus here.

        But your distinction between a plain text file and the .html output of your OP puzzles me again, as any difference should be negligible: the .html source is, to all intents and purposes as far as writing the file is concerned, a "plain text file."

        I know what you mean. In the end I suspect that it was just because when I tried sending the output as plain text it greatly reduced the number of lines I sent out. All the HTMLSTUFF was removed and my do_this sub was reduced to a few lines.

        sub do_this() { open FILE, "> $filename" or die "ERROR WRITTING FILE: $filename\nSyste +m reported $!"; print FILE "\n"; foreach (sort keys(%stuff1) ) { print FILE "$stuff1{$_} | ";} print FILE "\n"; foreach (sort keys(%stuff2) ) { print FILE "$stuff2{$_} | ";} close FILE; system "start /b $filename"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://784059]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-19 07:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found