|
|
ru.linux- RU.LINUX --------------------------------------------------------------------- From : Stas Vlasov 2:5080/172 07 May 2002 21:03:51 To : Andrew Martovlos Subject : Re: [perl] Прекомпилить perl-скрипт. -------------------------------------------------------------------------------- Tuesday May 07 2002, Andrew Martovlos writes to All: AM> Хочеться скомпилировать програму на perl'е, и запускать потом AM> бинарник. Hу, чтоб быстрее запускалась... AM> Куда копать? AM> Грабли есть? perldoc -q compile : Found in /usr/lib/perl5/5.6.1/pods/perlfaq3.pod How can I compile my Perl program into byte code or C? Malcolm Beattie has written a multifunction backend com- piler, available from CPAN, that can do both these things. It is included in the perl5.005 release, but is still con- sidered experimental. This means it's fun to play with if you're a programmer but not really for people looking for turn-key solutions. Merely compiling into C does not in and of itself guaran- tee that your code will run very much faster. That's because except for lucky cases where a lot of native type inferencing is possible, the normal Perl run-time system is still present and so your program will take just as long to run and be just as big. Most programs save little more than compilation time, leaving execution no more than 10-30% faster. A few rare programs actually benefit sig- nificantly (even running several times faster), but this takes some tweaking of your code. You'll probably be astonished to learn that the current version of the compiler generates a compiled form of your script whose executable is just as big as the original perl executable, and then some. That's because as cur- rently written, all programs are prepared for a full eval() statement. You can tremendously reduce this cost by building a shared libperl.so library and linking against that. See the INSTALL podfile in the Perl source distribution for details. If you link your main perl binary with this, it will make it minuscule. For example, on one author's system, /usr/bin/perl is only 11k in size! In general, the compiler will do nothing to make a Perl ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ program smaller, faster, more portable, or more secure. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ In fact, it can make your situation worse. The executable will be bigger, your VM system may take longer to load the whole thing, the binary is fragile and hard to fix, and compilation never stopped software piracy in the form of crackers, viruses, or bootleggers. The real advantage of the compiler is merely packaging, and once you see the size of what it makes (well, unless you use a shared libperl.so), you'll probably want a complete Perl install anyway. Все находится в документации. Судя по подчеркнутому, не поможет. Good luck. Stas --- Еще одно "золото" 1.1.5-20020105 * Origin: gui is good, but console better (2:5080/172) Вернуться к списку тем, сортированных по: возрастание даты уменьшение даты тема автор
Архивное /ru.linux/22873cd7ed98.html, оценка из 5, голосов 10
|