The example in this article describes the use of PHP to get folder size functions. Share to everyone for your reference. Specifically as follows:
?
Get folder Size
function Getdirsize ($dir)
{
$handle = Opendir ($dir);
while (false!== ($FolderOrFile = Readdir ($handle)))
{
if ($FolderOrFile!= "." $FolderOrFile!= "...")
{
if (Is_dir ("$dir/$FolderOrFile"))
{
$sizeResult + + getdirsize ("$dir/$FolderOrFile");
}
Else
{
$sizeResult + + filesize ("$dir/$FolderOrFile");
}
}
}
Clos
Exposure to computers all day, inevitably with a variety of measurement units to deal with, especially data, but you know bit, Byte, KB, GB, TB and so on all means how much data? Have you heard of EB, ZB, YB?
Bit (bit) is the initials of binary digit, the unit that measures information, and the smallest unit that represents the amount of content, only 0 or 12 binary states. 8 bits make up a byte (byte), can hold an English character, and a Chinese character requires two bytes of storage space,
specific steps:
Target: The 1G size, resolution 1080P, encoded as AVC HD video file transcoding for better clarity, small capacity, encoded as H. MP4 file. Compare the conversion time of the old and new platforms.
File information to be converted
Step One
First general set to output file resolution of 640*368 frame number is 12.500, the file encoding format is H. 2000Kbps, the average bitrate is as follows:
Step Two:
Transcoding on the new platform turns on Intel hardware acceleration, recor
priorities are changed by nice commands will also be calculated in the system and user time. Therefore, the total time may exceed.
II. memory information
Memory: 610008 K (24424 K) real, 995344 K (30304 K) virtual, 12588 K free Page #1/4
Memory: Memory usage statistics, including the actual (real) Memory activity value/total value, virtual Memory usage value/total value, and remaining Memory.
DESCRIPTION OF MEMORY
Mem: 9220 K Active, 1032 K Inact, 3284 K Wired, 1 MB Cache, 2 M Buf, 1320 K
Fre
times the function is recursive.The non-commonly used units TB, PB, EB, ZB please refer to the following notes (from the network):1bit (this bit represents a binary number)1Byte (this word is also called "bit") but it represents a hexadecimal number.1b=1byte=8bit1 KB = 1024x768 B (kb-kilobyte) thousand1 MB = KB (mb-megabyte) trillion1 GB = 1024x768 (gb-gigabyte)1 TB = 1024x768 (tb-terabyte) too1 PB = 1024x
the size of the uploaded object to a file unit that is easy to read. it can be converted to Bytes, KB, MB, GB, TB, PB, EB, ZB, YB, and other units.
Column 2
The code is as follows:
Function getDirSize ($ dir){$ Handle = opendir ($ dir );While (false! ==( $ FolderOrFile = readdir ($ handle ))){If ($ FolderOrFile! = "." $ FolderOrFile! = ".."){If (is_dir ("$ dir/$ FolderOrFile ")){$ SizeResult + = getDirSize ("$ dir/$ FolderOrFile ");}Else{$ SizeResult + = filesize (
identify how many times the function is recursive.
The non-commonly used units TB, PB, EB, ZB please refer to the following notes (from the network):
1bit (this bit represents a binary digit)1Byte (this word transliteration is also called "bit" but represents a hexadecimal number)1b=1byte=8bit1 KB = 1024x768 B (kb-kilobyte) thousand1 MB = KB (mb-megabyte) trillion1 GB = 1024x768 (gb-gigabyte)1 TB = 1024x76
as follows:
The code is as follows:
// Format the size displayFunction formatSize ($ B, $ times = 0 ){If ($ B gt; 1024 ){$ Temp = $ B/1024;Return formatSize ($ temp, $ times + 1 );} Else {$ Unit = 'B ';Switch ($ times ){Case '0': $ unit = 'B'; break;Case '1': $ unit = 'KB'; break;Case '2': $ unit = 'mb'; break;Case '3': $ unit = 'GB'; break;Case '4': $ unit = 'TB'; break;Case '5': $ unit = 'petab'; break;Case '6': $ unit = 'EB '; break;Case '7': $ unit = 'zb'; break;Default: $ unit = 'unknow
logic. Use the print command to display all usable tags. For example, (parted) set 1 boot on sets the boot tag of the partition numbered 1 to the on (effective) unit (set unit) format: unit: Select a unit that indicates the disk size for Parted. After that, all the numbers about the disk location (such as the start position of the partition) use this unit, and you don't need to give the unit suffix. (For example, if you select MB as the unit, 512 represents 512 MB, and you don't need to add mor
)。 #valu: # 0: 轮流方式,多个目录依次存放文件 # 2: 存储负载均衡。选择剩余空间最大的目录存放文件(注意:剩余磁盘空间是动态的,因此存储到的目录或磁盘可能也是变化的) store_path=0Download_server#func:下载服务器的选择方式。 #valu: # 0:轮询(默认) # 1:IP最小者 # 2:优先级排序(值最小的,优先级最高。) download_server=0Reserved_storage_space#func:保留空间值。如果某个组中的某个服务器的剩余自由空间小于设定值,则文件不会被上传到这个组。 #valu: # G or g for gigabyte # M or m for megabyte # K or k for kilobyte reserved_storage_space=1GBLog_level#func:日志级别 #valu: # eme
megabyte (s) vg permission: read/write TOTAL PPs: 546 (69888 megabytes) MAX LVs: 256 FREE PPs: 190 (24320 megabytes) LVs: 17 USED PPs: 356 (45568 megabytes) OPEN LVs: 16 QUORUM: 2 (Enabled) TOTAL PVs: 1 vg descriptors: 2 STALE PVs: 0 STALE PPs: 0 ACTIVE PVs: 1 auto on: yesMAX PPs per VG: 32512 MAX PPs per PV: 1016 MAX PVs: 32LTG size (Dynamic): 256 kilobyte (s) auto sync: noHOT SPARE: no bb policy: relocat
The approximate program idea is to use the recursive rules to calculate the amount of space occupied by the directory, and then the value of the space to write into the text file, so long as the access to the TXT file will know how much space occupied, do not have to read the disk frequently, save resources. Each time a user uploads a file or deletes a file, it is re-counted. Of course, you can also save the statistical results in the database.
Copy the Code code as follows:
function Countdirsi
Byte: bytes are units that transmit information over the network (or store information in hard disks or in memory).Bytes are a unit of measurement used by computer information technology to measure storage capacity and transmission capacity, with 1 bytes equal to 8-bit binary.In ASCII, an English letter (not case) occupies a single byte of space, and a Chinese character occupies two bytes of space.Symbol: English punctuation occupies one byte, Chinese punctuation is two bytes. Example: "." 1 byt
Computer storage unit bit (BIT) (binary digits): stores a bit of binary, that is, 0 or 1, the smallest storage unit. Byte: eight binary bits are one byte (B), the most common unit. That is, 1B (byte bytes) = 8 bit computer storage units are generally represented by B, kb, MB, GB, TB, Pb, EB, ZB, Yb, BB, the relationship between them is: 1 kb (kilobyte kilobytes) = 1024b, 1 MB (megabyte megabytes referred to
group, I only need to operate on it..
2. view the volume group information========================================================== ============================================
# Lsvg rootvgVolume group: rootvg identifier: 00098d9f00004c00000000f9b120700bVG state: Active pp size: 64 megabyte (s)VG permission: read/write total PPS: 542 (34688 megabytes)
Max LVS: 256 free PPS: 390 (24960 megabytes)
LVS: 9 used PPS: 152 (9728 megabytes)
Open LVS: 8 quo
Bit (BIT) (binary digits): stores a bit of binary, that is, 0 or 1, the smallest storage unit.
Byte: eight binary bits are one byte (B), the most common unit.
Generally, the computer storage unit is represented by B, kb, MB, GB, TB, Pb, EB, ZB, Yb, and BB. The relationship between them is:
1kb (kilobyte kilobytes) = 1024b,
1 MB (megabyte MB for short) = 1024kb,
1 GB (gigabyte, also known as "Gigabit"
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.