assembly codes inside perl?
Hi, Has anyone done some Assembly Language Programming inserted into Perl scripts? If so, can you show a sample? I am in need of speeding up a very recursive function; in perl, it took almost an hour; in C++, it took a few seconds. I wanted more speed. thanks. Jaime Email Advisory== To ensure delivery of message to [EMAIL PROTECTED], please contact your email provider and ask them if your email server has a valid DNS entry. Public Email Servers must have a valid hostname and routeable public IP Address per RFC1912 compliance. To test the compliance of your email server, please send an email to: [EMAIL PROTECTED]; our server will reply with a result within minutes. ==Email Advisory ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: assembly codes inside perl?
Could you be a little more specific please ? It might be the case that it is not a language problem but an implementation problem with a discrepancy that big. On Wed, 23 Jun 2004, Jaime Teng wrote: Hi, Has anyone done some Assembly Language Programming inserted into Perl scripts? If so, can you show a sample? I am in need of speeding up a very recursive function; in perl, it took almost an hour; in C++, it took a few seconds. I wanted more speed. thanks. Jaime -- Angelos Karageorgiou Masters of Computer Science City University of New York http://www.unix.gr ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: assembly codes inside perl?
You may want to look at your Perl code first. I can't see such a big difference between C++ and Perl. -Original Message- From: Jaime Teng [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 23, 2004 9:26 AM To: [EMAIL PROTECTED] Subject: assembly codes inside perl? Hi, Has anyone done some Assembly Language Programming inserted into Perl scripts? If so, can you show a sample? I am in need of speeding up a very recursive function; in perl, it took almost an hour; in C++, it took a few seconds. I wanted more speed. thanks. Jaime Email Advisory== To ensure delivery of message to [EMAIL PROTECTED], please contact your email provider and ask them if your email server has a valid DNS entry. Public Email Servers must have a valid hostname and routeable public IP Address per RFC1912 compliance. To test the compliance of your email server, please send an email to: [EMAIL PROTECTED]; our server will reply with a result within minutes. ==Email Advisory ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: assembly codes inside perl?
I've seen improvements on this scale by replacing Perl code with C. I had a dynamic-programming string comparison algorithm, which compares all the subsequences of a short string against a longer one. It creates an array of size approximately 500x20, and reuses the same array every time to avoid creating a new one and garbage collecting old ones. The program calls the comparison function to populate and search this table somewhere around 20'000 times. I tried this in perl first, and profiled it using the -d:DProf option. The time per call was 0.0095 seconds, giving a total cumulative time of 186 seconds for 2 calls. I replaced the perl function with the C equivalent embedded in the Perl using Inline::C. On the same dataset, the cumulative time taken up by the calls was only 1.28 seconds. I suspect the speed up was due to the sheer speed with which C can access arrays compared to Perl. -Original Message- From: Bharucha, Nikhil [mailto:[EMAIL PROTECTED] Sent: 23 June 2004 14:39 To: Jaime Teng; [EMAIL PROTECTED] Subject: RE: assembly codes inside perl? You may want to look at your Perl code first. I can't see such a big difference between C++ and Perl. -Original Message- From: Jaime Teng [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 23, 2004 9:26 AM To: [EMAIL PROTECTED] Subject: assembly codes inside perl? Hi, Has anyone done some Assembly Language Programming inserted into Perl scripts? If so, can you show a sample? I am in need of speeding up a very recursive function; in perl, it took almost an hour; in C++, it took a few seconds. I wanted more speed. thanks. Jaime Email Advisory== To ensure delivery of message to [EMAIL PROTECTED], please contact your email provider and ask them if your email server has a valid DNS entry. Public Email Servers must have a valid hostname and routeable public IP Address per RFC1912 compliance. To test the compliance of your email server, please send an email to: [EMAIL PROTECTED]; our server will reply with a result within minutes. ==Email Advisory ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs This message contains confidential and potentially legally privileged information solely for its intended recipients and others may not distribute, copy or use it. If you have received this communication in error, please tell us by return email and delete it, and any copies of it. ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: assembly codes inside perl?
At 15:25 2004-06-23, Jaime Teng wrote: Has anyone done some Assembly Language Programming inserted into Perl scripts? If so, can you show a sample? I am in need of speeding up a very recursive function; in perl, it took almost an hour; in C++, it took a few seconds. I wanted more speed. You want Inline::C or Inline::CPP then. There may be some for your assembler also. Look here: http://search.cpan.org/search?query=inline http://search.cpan.org/~ingy/Inline-0.44/Inline.pod C and C++ http://search.cpan.org/~ingy/Inline-0.44/C/C.pod http://search.cpan.org/~neilw/Inline-CPP-0.25/lib/Inline/CPP.pod Very cool stuff! /J -- --- -- -- -- - - -- - Johan LindströmSourcerer @ Boss Casinos johanl AT DarSerMan.com Latest bookmark: Auto-Increment and DBD Agnosticism http://www.perlmonks.org/index.pl?node_id=368814 dmoz: /Computers/Software/Operating_Systems/Linux/ 40 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: assembly codes inside perl?
Never forget that most often there are 3,4,5 ways of doing something in Perl. Some ways are slower but may not seem so unless under heavy load. Perl meets my needs and is very fast with arrays. Of course if you have a process that performs something like a simple math function many many times then the only way to guarantee that it is doing so efficiently is to code it in Assembler where you have full control. We had a situation where compiled C code was performing 9 instructions where it was replaced by 1 instruction in Assembler. The example immediately below would probably be even faster if coded in Assembler -- but Assembler should be the last resort. -Original Message- From: Mark Harris [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 23, 2004 10:03 AM To: [EMAIL PROTECTED] Subject: RE: assembly codes inside perl? I've seen improvements on this scale by replacing Perl code with C. I had a dynamic-programming string comparison algorithm, which compares all the subsequences of a short string against a longer one. It creates an array of size approximately 500x20, and reuses the same array every time to avoid creating a new one and garbage collecting old ones. The program calls the comparison function to populate and search this table somewhere around 20'000 times. I tried this in perl first, and profiled it using the -d:DProf option. The time per call was 0.0095 seconds, giving a total cumulative time of 186 seconds for 2 calls. I replaced the perl function with the C equivalent embedded in the Perl using Inline::C. On the same dataset, the cumulative time taken up by the calls was only 1.28 seconds. I suspect the speed up was due to the sheer speed with which C can access arrays compared to Perl. -Original Message- From: Bharucha, Nikhil [mailto:[EMAIL PROTECTED] Sent: 23 June 2004 14:39 To: Jaime Teng; [EMAIL PROTECTED] Subject: RE: assembly codes inside perl? You may want to look at your Perl code first. I can't see such a big difference between C++ and Perl. -Original Message- From: Jaime Teng [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 23, 2004 9:26 AM To: [EMAIL PROTECTED] Subject: assembly codes inside perl? Hi, Has anyone done some Assembly Language Programming inserted into Perl scripts? If so, can you show a sample? I am in need of speeding up a very recursive function; in perl, it took almost an hour; in C++, it took a few seconds. I wanted more speed. thanks. Jaime Email Advisory== To ensure delivery of message to [EMAIL PROTECTED], please contact your email provider and ask them if your email server has a valid DNS entry. Public Email Servers must have a valid hostname and routeable public IP Address per RFC1912 compliance. To test the compliance of your email server, please send an email to: [EMAIL PROTECTED]; our server will reply with a result within minutes. ==Email Advisory ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs This message contains confidential and potentially legally privileged information solely for its intended recipients and others may not distribute, copy or use it. If you have received this communication in error, please tell us by return email and delete it, and any copies of it. ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: assembly codes inside perl?
I am in need of speeding up a very recursive function; in perl, it took almost an hour; in C++, it took a few seconds. I wanted more speed. More often than not, you can speed up a Perl program considerably by improving the algorithm you're using. You may not need to drop into C. Perhaps you can show the code in question. Otherwise I'd suggest Inline::C. -- Mark Thomas[EMAIL PROTECTED] Internet Systems Architect DigitalNet, Inc. $_=q;KvtuyboopuifeyQQfeemyibdlfee;; y.e.s. ;y+B-x+A-w+s; ;y;y; ;;print;; ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs