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 Wed 01 Oct 2014, 13:09
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
A Q of methods for importing variables.
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 1 of 1 Posts_count  
Author Message
sunburnt


Joined: 08 Jun 2005
Posts: 5032
Location: Arizona, U.S.A.

PostPosted: Sun 24 Jun 2012, 02:47    Post_subject:  A Q of methods for importing variables.  

I think technosaurus kinda answered this awhile back.

# I wondered about the ram used by a hook file by the 3 methods.

1) If a literal string is used in a script, it takes ram up when it`s run.

2) A variable by argument, has to hold the value in ram somehow,

3) When a variable is exported, it`s value is stored in ram.

So there`s little difference in ram used by the methods... Correct?
The only difference I see, is 1 and 2 only use ram if the file`s run.

This seems to make good sense to me. Any thoughts or clarifications?
.

Edited_time_total
Back to top
View user's profile Send_private_message 
jpeps

Joined: 31 May 2008
Posts: 3220

PostPosted: Sun 24 Jun 2012, 03:52    Post_subject:  

How many variables are you talking about? I tried exporting 25 strings, and got no diff running "free" before and after.

edit: made a mistake...got a difference. You can run a script at check it.

Edited_time_total
Back to top
View user's profile Send_private_message 
sunburnt


Joined: 08 Jun 2005
Posts: 5032
Location: Arizona, U.S.A.

PostPosted: Sun 24 Jun 2012, 04:04    Post_subject:  

But then, where is the variable=value held?

I`m guessing it`s reserved ram so it already shows as ram used.
That being case, it doesn`t matter as it doesn`t impact free ram.

I don`t know enough about the manner that Linux does this.

My main Q was any difference in the ram use by the 3 methods.
Back to top
View user's profile Send_private_message 
jpeps

Joined: 31 May 2008
Posts: 3220

PostPosted: Sun 24 Jun 2012, 04:12    Post_subject:  

sunburnt wrote:
But then, where is the variable=value held?

I`m guessing it`s reserved ram so it already shows as ram used.
That being case, it doesn`t matter as it doesn`t impact free ram.

I don`t know enough about the manner that Linux does this.

My main Q was any difference in the ram use by the 3 methods.


Edited my first post. Run a script, with "free" before and after all methods to see the diffs.

edit: too crude a test (too much sd).
edit: I don't see much difference with and without "export" over a repeated trials (although it would make sense that exporting would store them longer in the stack)
Back to top
View user's profile Send_private_message 
amigo

Joined: 02 Apr 2007
Posts: 2252

PostPosted: Sun 24 Jun 2012, 05:20    Post_subject:  

Linux(kernel) doesn't have any thing to do with it -it's the sehll which is allocating memory (through libc). You will be hard-pressed to demonstrate any difference at all, I think. I wouldn't worry about how much RAM the sehll is using -except: When you use lots of functions you could see RAM usage increase visibly. For scripts under 1,000 lines I wouldn't worry about it at all.

My src2pkg contains more than 10,000 lines of functions which are sourced -that is read into RAM for later execution. With such an amount, you can see increased RAM usage. But that is offset by the quicker execution of the code. Interpreting while reading line-by-line from a script is slower that first reading the code into RAM and then running it later -at least for large functions. There is a difference between running code directly as opposed to calling it from a function when the code bit is small.

I use lots of functions because of all the benefits of doing so.
Back to top
View user's profile Send_private_message 
technosaurus


Joined: 18 May 2008
Posts: 4351

PostPosted: Tue 26 Jun 2012, 01:20    Post_subject:  

as Amigo stated, the speed difference between using a function and a separate script can be extreme - this is especially true for something that is used many times such as recursive functions, but I wouldn't worry too much about the resources, I converted nearly every default puppy script to a function and it was barely noticeable for small scripts (busybox time said it was the same when using ash, but bash did show a slow down slightly - bash's time shows 1 more significant digit)

... but for larger scripts that called several other scripts, but now just called functions, there was significantly measurable speedups in both ash and bash (see the bashbox thread for more info)

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send_private_message 
sunburnt


Joined: 08 Jun 2005
Posts: 5032
Location: Arizona, U.S.A.

PostPosted: Tue 26 Jun 2012, 16:45    Post_subject:  

Thanks technosaurus; Function libraries are a farorite for portability.

Your right amigo; I tend to think of the kernel`s handling of everything.
But it`s more the piece of software that`s running at the moment.


I ran tests and the ram usage was all over the place,
not much difference between the 3 methods at all.
Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Off-Topic Area » Programming
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1020s ][ Queries: 12 (0.0189s) ][ GZIP on ]