Skip to content

Instantly share code, notes, and snippets.

@mu-mu-mu
Created April 9, 2021 05:34
Show Gist options
  • Save mu-mu-mu/9cabb073f9eb92a164c09eec7e7ed56c to your computer and use it in GitHub Desktop.
Save mu-mu-mu/9cabb073f9eb92a164c09eec7e7ed56c to your computer and use it in GitHub Desktop.
Demand Paging
#include <iostream>
#include <chrono>
#include <sys/mman.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
using namespace std;
int main(){
mlockall(MCL_FUTURE);
std::chrono::system_clock::time_point start, end;
start = std::chrono::system_clock::now();
auto tt = new char[4194304];
memset(tt, 0, 4194304);
end = std::chrono::system_clock::now();
auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end-start).count();
cout << elapsed << endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment