java
System.out.println(System.currentTimeMillis());
try{
File baidu = new File("d:\\java\\1.txt");
FileInputStream fis = new FileInputStream(baidu);
String str = "";
byte[] bytes = new byte[1024*1024];
int length = 0;
while ((length = fis.read(bytes)) != -1)
{
str += new String(bytes, 0, length);
}
// System.out.println(str);
}catch(FileNotFoundException e){
e.printStackTrace();
} catch (IOException e){
e.printStackTrace();
}
System.out.println(System.currentTimeMillis());
//结果----------------------------------------------------------
1480761870536
1480761870915
小半秒
php
echo microtime()."<br>";
file_get_contents("D:/java/1.txt");
echo microtime();
//结果----------------------------------------------------------
0.71839400 1480761810
0.74239000 1480761810
0.024秒
System.out.println(System.currentTimeMillis());
try{
File baidu = new File("d:\\java\\1.txt");
FileInputStream fis = new FileInputStream(baidu);
String str = "";
byte[] bytes = new byte[1024*1024];
int length = 0;
while ((length = fis.read(bytes)) != -1)
{
str += new String(bytes, 0, length);
}
// System.out.println(str);
}catch(FileNotFoundException e){
e.printStackTrace();
} catch (IOException e){
e.printStackTrace();
}
System.out.println(System.currentTimeMillis());
//结果----------------------------------------------------------
1480761870536
1480761870915
小半秒
php
echo microtime()."<br>";
file_get_contents("D:/java/1.txt");
echo microtime();
//结果----------------------------------------------------------
0.71839400 1480761810
0.74239000 1480761810
0.024秒