在使用新硬件时,我编写了一段C代码来测试RAM速度和磁盘速度.基本上它是3行在RAM中写入5 GB并将其写入文件,我在其周围设置了一些定时器:
long long int AMOUNT = 5*1024*1024*1024l;
FILE *file_handle = fopen('test.bin', 'wb');
handle = malloc(AMOUNT);
memset(handle, 0, AMOUNT);
fwrite(handle, AMOUNT, 1, file_handle);
Run Code Online (Sandbox Code Playgroud)
然后我用dd使用ramdisk或tempfs尝试了它:
mount -t tmpfs /mnt/temp1 /mnt/temp1
dd if=/dev/zero of=/mnt/temp1/test bs=1M
Run Code Online (Sandbox Code Playgroud)
并且,回到磁盘:
dd if=/mnt/temp1/test of=/home/user/test bs=1M
Run Code Online (Sandbox Code Playgroud)
在下表中,我的结果,我也插入了速度记忆7.5.我不明白9.0和memtest与其他数字之间的巨大差异......任何人都能解释一下吗?
以下javascript代码并不是我所期望的.这是在ajax调用的成功执行的代码,但是:虽然在$ .each value1.html_id和redraw或reload的某些轮次相等(并且它们都是字符串),if(){}代码永远不会被执行.我在这里错过了什么?
if语句外部的console.log()被执行,我可以看到值是相同的,但if的{}中的代码永远不会被执行
success: function(result) {
activaTab(tab_id);
$.each(tables, function(key, value1) {
console.log(value1.html_id + redraw + reload)
if (value1.html_id == redraw) {
console.log('works');
value1.table.columns.adjust().draw();
}
if (value1.html_id == reload) {
console.log('works2');
value1.table.ajax.reload(null, false);
}
});
}
Run Code Online (Sandbox Code Playgroud)
控制台每次都看起来像这样(在ifs之外的324行)
scr_table2.js:324 scr-tablescr_tablescr_table1
scr_table2.js:324 scr-table1scr_tablescr_table1
scr_table2.js:324 scr-table2scr_tablescr_table1
scr_table2.js:324 scr-table3scr_tablescr_table1
Run Code Online (Sandbox Code Playgroud) 我在PHP和带有Boost的C ++中都具有以下实现。它只是将文件读取为字符串,将其用空格分隔(我希望能够选择此字符),然后在具有20万个以空格分隔的随机数(称为“空格”)的文件上运行:
在PHP中:
<?php
$a = explode(" ", file_get_contents("spaces"));
echo "Count: ".count($a)."\n";
foreach ($a as $b) {
echo $b."\n";
}
Run Code Online (Sandbox Code Playgroud)
在C ++中:
#include <boost/algorithm/string.hpp>
#include <string>
#include <vector>
#include <iostream>
#include <fstream>
#include <sstream>
#include <stdio.h>
using namespace boost;
using namespace std;
int main(int argc, char* argv[])
{
// ifstream ifs("spaces");
// string s ((istreambuf_iterator<char>(ifs)), (istreambuf_iterator<char>()));
char * buffer = 0;
long length;
string filename = "spaces";
FILE * f = fopen (filename.c_str(), "rb");
if (f)
{
fseek (f, 0, …Run Code Online (Sandbox Code Playgroud) boost ×1
c ×1
c++ ×1
dd ×1
if-statement ×1
javascript ×1
jquery ×1
memory ×1
performance ×1
php ×1
ram ×1