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 Sat 23 Aug 2014, 00:00
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 [1 Post]  
Author Message
matiasbatero


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

PostPosted: Fri 13 Sep 2013, 00:25    Post subject:  Compiling script functions with ZSH to get speed
Subject description: 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:

Code:
↗ 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:
https://github.com/henrikbrixandersen/dotfiles/blob/master/.zsh/help/zcompile

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:

Code:
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 from previous:   Sort by:   
Page 1 of 1 [1 Post]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


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