Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 30 Jun 2015, 17:40
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Compiling script functions with ZSH to get speed
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 1 of 1 Posts_count_1  
Author Message

Joined: 11 Oct 2012
Posts: 60
Location: Mar del Plata, Argentina

PostPosted: Fri 13 Sep 2013, 00:25    Post_subject:  Compiling script functions with ZSH to get speed
Sub_title: zcompile (zsh-builtin) to compile functions on ZShell

Hi Friends.

Compiling functions with ZSH (bytecode)

My motivation:

I'm developed a bash script that scans ( PS/2 port ) for mouse devices, that decode raw data (hex raw code) in real information about movements (in real time).

The script returns 3 columns of data only if mouse state is ON:
OFF state doesn't write ouput.

a) Unicode arrow - To identify direction: ← ↑ → ↓ ↖ ↗ ↘ ↙
b) X - Units of x-axis displacement since start-reference.
c) Y - Units of y-axis displacement since start-reference.
c) Time [s:ss] in centiseconds

Like this:

↗ 2 15 5.98

The script runs fine with very very great speed. But.. like always, if it's possible to give the maximum potential.. i will do it.

Searching, i discovered that ZSH, KSH, SCSH have this feature (compiler built-in). I don't have a lot of time to do a deep test, but.. it's a great option, that some can use to get some speed on their scripts.

zcompile Documentation is very poor & hide. But i found a nice document:

This builtin command can be used to compile functions or scripts, storing the compiled form in a file, and to examine files containing the compiled form. This allows faster autoloading of functions and execution of scripts by avoiding parsing of the text when the files are read.

Basically, it's very simple to use:

zcompile function

That produces a .zwc file 2.5X bigger (approx). That you call in your script, using <autoload> if you want.

Well, hope that it will usefull.
>> Sorry for my english.[/code]
Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 1 of 1 Posts_count_1  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot attach files in this forum
You can download files in this forum

Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0383s ][ Queries: 11 (0.0026s) ][ GZIP on ]