07-17-2011
Opening a file takes time. So if possible, you should open each file only once (or the minimum number of times you can) and get everything you might need and save it in memory (in variables).
OTOH, I understand that the way Linux works now is to use all unused RAM as cache. So if you open a file, search it and close it, the whole file will stay cached in RAM until some other allocation causes it to be discarded. The result is that the second open will probably be almost instantaneous.
Of course, if you have many more files than will fit in your available RAM, then you'll lose the cache advantage.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I'm trying to do two different things (converting an OpenVms .com to a ksh shell script): 1) open/read/err= 2) open/write/err=
Any help? I've found some things, but can't seem to find the correct way. (1 Reply)
Discussion started by: prosserj
1 Replies
2. Shell Programming and Scripting
Hello
Can someone help me to write a perl script or kornshell reading a two files and outputting to comma format.
Here is the two files
listofdisks.txt
id, diskname, diskgroup, diskisze(GB), FC
1, CN34, GRP1, 30, FC_CN34
2, CN67, GRP5, 19,
4, VD1, GRP4, 23, FC_VD1
6, CF_D1, ... (0 Replies)
Discussion started by: deiow
0 Replies
3. Shell Programming and Scripting
I have a question regarding Perl scripting.
If I want to say open files that all look like this and assign them to a filehandle and then assign the filehandle to a variable, how do I do this?
The file names are
strand1.fa.gz.tmp
strand2.fa.gz.tmp
strand3.fa.gz.tmp
strand4.fa.gz.tmp
...... (6 Replies)
Discussion started by: japaneseguitars
6 Replies
4. Solaris
How do I find all "regular" files on solaris(8) that are open for write ( +read as well).
I tried using pfiles, and lsof commands, but not sure how to get exactly what I wanted.
ps -e | awk '{ print $1 }' | xargs -i pfiles {} 2>/dev/null (10 Replies)
Discussion started by: kchinnam
10 Replies
5. Homework & Coursework Questions
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
I must write a shell script that calls two external Perl functions--one of which sorts the data in a file, and... (6 Replies)
Discussion started by: kowit010
6 Replies
6. Shell Programming and Scripting
Hi everybody!
I'm trying to delete some elements from a list with two elements on each row agreeing with the elements in another list. Pratically I want a perl script able to take each element of the second list (that is a single column list), compare it with both elements of each row from the... (3 Replies)
Discussion started by: gabrysfe
3 Replies
7. Shell Programming and Scripting
Hi All,
I would like to use a Perl (not Bash) script to work with multiple files of the same name in different directories (all in the same parent directory). I tried to create a loop to do so, but it isn't working.
My code so far:
while (defined(my $file = glob("./*/filename.txt")) or... (1 Reply)
Discussion started by: elgo4
1 Replies
8. Shell Programming and Scripting
Hello!
I am a real beginner in scripting, so I am struggling with a really easy task!
I want to write a script to concatenate several text files onto each other and generate a new file. I wanted the first argument to be the name of the new file, so:
./my_script.sh new_file file1.txt... (5 Replies)
Discussion started by: malajedala
5 Replies
9. Shell Programming and Scripting
help me (1 Reply)
Discussion started by: sonu pandey
1 Replies
10. UNIX for Beginners Questions & Answers
hi,
Hope you are doing good.
During my coding yesterday i got this challenge, actually not a challenge it like to optimize the code.
I am printing some statement to monitor the file progress in the log file an also to display it in the screen. so i ended up in the below statements.
... (6 Replies)
Discussion started by: mad man
6 Replies
LEARN ABOUT PHP
wincache_ocache_fileinfo
WINCACHE_OCACHE_FILEINFO(3) 1 WINCACHE_OCACHE_FILEINFO(3)
wincache_ocache_fileinfo - Retrieves information about files cached in the opcode cache
SYNOPSIS
array wincache_ocache_fileinfo ([bool $summaryonly = false])
DESCRIPTION
Retrieves information about opcode cache content and its usage.
PARAMETERS
o $summaryonly
- Controls whether the returned array will contain information about individual cache entries along with the opcode cache summary.
RETURN VALUES
Array of meta data about opcode cache or FALSE on failure
The array returned by this function contains the following elements:
o total_cache_uptime - total time in seconds that the opcode cache has been active
o total_file_count - total number of files that are currently in the opcode cache
o total_hit_count - number of times the compiled opcode have been served from the cache
o total_miss_count - number of times the compiled opcode have not been found in the cache
o is_local_cache - true is the cache metadata is for a local cache instance, false if the metadata is for the global cache
o file_entries - an array that contains the information about all the cached files:
o file_name - absolute file name of the cached file
o add_time - time in seconds since the file has been added to the opcode cache
o use_time - time in seconds since the file has been accessed in the opcode cache
o last_check - time in seconds since the file has been checked for modifications
o hit_count - number of times the file has been served from the cache
o function_count - number of functions in the cached file
o class_count - number of classes in the cached file
EXAMPLES
Example #1
A wincache_ocache_fileinfo(3) example
<pre>
<?php
print_r(wincache_ocache_fileinfo());
?>
</pre>
The above example will output:
Array
(
[total_cache_uptime] => 17357
[total_file_count] => 121
[total_hit_count] => 36562
[total_miss_count] => 201
[file_entries] => Array
(
[1] => Array
(
[file_name] => c:inetpubwwwrootcheckcache.php
[add_time] => 17356
[use_time] => 7
[last_check] => 10
[hit_count] => 454
[function_count] => 0
[class_count] => 1
)
[2] => Array (...iterates for each cached file)
)
)
SEE ALSO
wincache_fcache_fileinfo(3), wincache_fcache_meminfo(3), wincache_ocache_meminfo(3), wincache_rplist_fileinfo(3), wincache_rplist_mem-
info(3), wincache_refresh_if_changed(3), wincache_ucache_meminfo(3), wincache_ucache_info(3), wincache_scache_info(3), wincache_scache_mem-
info(3).
PHP Documentation Group WINCACHE_OCACHE_FILEINFO(3)