php - Performant way to get large list of files with modified date and size -


i using php 5.6 on linux. getting list of files , directories in directory

$directory_listing = scandir($path); 

i know similar following array of filenames plus modified date , size.

$listings_final = array(); foreach ($directory_listing $listing) {     $listings_final[]['listing_name'] = $listing;     $listings_final[]['listing_modified'] = filemtime($listing);     $listings_final[]['listing_size'] = filesize($listing); } 

this slow when number of files extremely large. there more performant way archive this?

not likely. in accessing filesystem, metadata each file grabbed per file, not in bulk. relatively low-level tools ls way. if have 10,000 files in directory, there's not going way around making 10,000 separate calls grab metadata of files. there may tool purports in 1 go, it's going abstracting fact it's looping through files in directory information, , isn't going faster.

the way know of create accesses filesystem directly information. however, not recommended, makes application dependent on specific filesystems (i.e. ext4).

your best bet going to grab initial file listing directory , populate that, since can done quickly. then, asynchronously, grab metadata each file , populate application. way, user can begin interact application without having wait of metadata load.


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -