2010-01-21 00:03:17 +00:00
|
|
|
#include <stasis/transactional.h>
|
|
|
|
#include <stasis/bufferManager.h>
|
|
|
|
|
2006-04-12 01:41:35 +00:00
|
|
|
#include <assert.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2009-08-22 00:01:02 +00:00
|
|
|
|
2006-04-12 01:41:35 +00:00
|
|
|
#include <unistd.h>
|
2008-04-13 04:02:57 +00:00
|
|
|
#include <stasis/page/raw.h>
|
2006-04-12 01:41:35 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2009-08-22 00:01:02 +00:00
|
|
|
int main(int argc, char** argv) {
|
2006-04-12 01:41:35 +00:00
|
|
|
assert(argc == 3);
|
2009-08-22 00:01:02 +00:00
|
|
|
|
2006-04-12 01:41:35 +00:00
|
|
|
#define ZEROCOPY 0
|
|
|
|
#define LSNMODE 1
|
|
|
|
|
|
|
|
int mode = atoi(argv[1]);
|
|
|
|
|
|
|
|
int count = atoi(argv[2]);
|
|
|
|
|
|
|
|
int longsPerPage = PAGE_SIZE / sizeof(long);
|
|
|
|
|
2009-08-22 00:01:02 +00:00
|
|
|
if(ZEROCOPY == mode) {
|
2006-04-12 01:41:35 +00:00
|
|
|
printf("Running ZEROCOPY mode. Count = %d\n", count);
|
|
|
|
}
|
|
|
|
|
|
|
|
Tinit();
|
|
|
|
int xid = Tbegin();
|
|
|
|
|
|
|
|
long * buf = malloc(longsPerPage * sizeof(long));
|
2009-08-22 00:01:02 +00:00
|
|
|
|
|
|
|
for(int i = 0; i < count; i++) {
|
2006-04-12 01:41:35 +00:00
|
|
|
int pageNum = TpageAlloc(xid);
|
|
|
|
|
|
|
|
Page * p = loadPage(xid, pageNum);
|
2009-08-22 00:01:02 +00:00
|
|
|
if(ZEROCOPY == mode) {
|
2006-04-12 01:41:35 +00:00
|
|
|
long * data = (long*) rawPageGetData(xid, p);
|
|
|
|
for(int j = 0; j < longsPerPage; j++) {
|
|
|
|
data[j] = j;
|
|
|
|
}
|
2009-10-15 02:33:08 +00:00
|
|
|
rawPageSetData(xid, 0, p); // XXX writelatch!
|
2009-08-22 00:01:02 +00:00
|
|
|
} else if(LSNMODE == mode) {
|
2006-04-12 01:41:35 +00:00
|
|
|
long * data = (long*) rawPageGetData(xid, p);
|
|
|
|
memcpy(buf, data, PAGE_SIZE);
|
|
|
|
for(int j = 0; j < longsPerPage; j++) {
|
|
|
|
buf[j] = j;
|
|
|
|
}
|
|
|
|
memcpy(data, buf, PAGE_SIZE);
|
|
|
|
|
|
|
|
rawPageSetData(xid, 0, p);
|
|
|
|
}
|
|
|
|
releasePage(p);
|
|
|
|
|
|
|
|
}
|
|
|
|
Tcommit(xid);
|
|
|
|
Tdeinit();
|
|
|
|
}
|