zoukankan      html  css  js  c++  java
  • 大数据文件和小数据文件读取

    小数据文件:file_get_contents

    大数据:fgets

    <?php

            $file = "log.txt";
            $handle = @fopen($file, "r");
            $begin_arr = explode(" ", microtime());
            echo "start: ".$begin_arr[1]."<br>";
            if ($handle)
            {
                  flock($handle, LOCK_EX);//只有file函数读写才能有效
                $i = 1;
                while (!feof($handle))
                {
                    $buffer = fgets($handle);
                    $i++;
                }
                 echo  "<br>run: ".$i;
                 
                  $end_arr = explode(" ", microtime());
                 echo "end: ".$end_arr[1]."<br>";
                echo $end_arr[1] -$begin_arr[1];
                flock($handle, LOCK_UN);
                fclose($handle);
            }
    ?>

  • 相关阅读:
    arm单板上移植gdb
    video on web
    chromium源码阅读
    CE-HTML简介
    multi-tap
    DPDK 网卡RSS(receive side scaling)简介
    c语言实现带LRU机制的哈希表
    Linux TCP协议使用的变量
    scp源码浅析
    Linux e1000e网卡驱动
  • 原文地址:https://www.cnblogs.com/legend-song/p/5195609.html
Copyright © 2011-2022 走看看