mirror of
https://github.com/clearlinux/graphene.git
synced 2026-09-04 04:41:37 +00:00
[tests] Add basic benchmarks
This commit is contained in:
committed by
Dmitrii Kuvaiskii
parent
a004123d92
commit
e596be0662
@@ -0,0 +1,3 @@
|
||||
/__pycache__/
|
||||
/helloworld
|
||||
/write_pages
|
||||
@@ -0,0 +1,10 @@
|
||||
BENCHMARKS = \
|
||||
helloworld \
|
||||
write_pages
|
||||
|
||||
.PHONY: all
|
||||
all: $(BENCHMARKS)
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
$(RM) $(BENCHMARKS)
|
||||
@@ -0,0 +1,21 @@
|
||||
#sgx.enable_stats = 1
|
||||
|
||||
loader.preload = file:@GRAPHENEDIR@/Runtime/libsysdb.so
|
||||
loader.env.LD_LIBRARY_PATH = /lib
|
||||
loader.debug_type = none
|
||||
loader.syscall_symbol = syscalldb
|
||||
loader.insecure__use_cmdline_argv = 1
|
||||
|
||||
fs.mount.graphene_lib.type = chroot
|
||||
fs.mount.graphene_lib.path = /lib
|
||||
fs.mount.graphene_lib.uri = file:@GRAPHENEDIR@/Runtime
|
||||
|
||||
sgx.trusted_files.ld = file:@GRAPHENEDIR@/Runtime/ld-linux-x86-64.so.2
|
||||
sgx.trusted_files.libc = file:@GRAPHENEDIR@/Runtime/libc.so.6
|
||||
sgx.trusted_files.libdl = file:@GRAPHENEDIR@/Runtime/libdl.so.2
|
||||
sgx.trusted_files.libm = file:@GRAPHENEDIR@/Runtime/libm.so.6
|
||||
sgx.trusted_files.libpthread = file:@GRAPHENEDIR@/Runtime/libpthread.so.0
|
||||
|
||||
sgx.thread_num = 3
|
||||
|
||||
#sgx.static_address = 1
|
||||
@@ -0,0 +1,34 @@
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
# Copyright (c) 2020 Intel Corporation
|
||||
# Wojtek Porczyk <woju@invisiblethingslab.com>
|
||||
#
|
||||
|
||||
from . import Exec
|
||||
|
||||
# pylint: disable=invalid-name
|
||||
|
||||
class HelloWorld:
|
||||
# pylint: disable=no-self-use
|
||||
|
||||
helloworld = Exec('helloworld', manifest_template='basic.manifest.template')
|
||||
setup = helloworld.setup
|
||||
|
||||
def time_graphene_nosgx(self):
|
||||
self.helloworld.run_in_graphene(sgx=False)
|
||||
|
||||
def time_graphene_sgx(self):
|
||||
self.helloworld.run_in_graphene(sgx=True)
|
||||
|
||||
class WritePages:
|
||||
# pylint: disable=no-self-use
|
||||
|
||||
write_pages = Exec('write_pages', manifest_template='basic.manifest.template')
|
||||
params = [10000, 100000, 1000000, 10000000]
|
||||
param_names = ['pagecount']
|
||||
setup = write_pages.setup
|
||||
|
||||
def time_graphene_nosgx(self, pagecount):
|
||||
self.write_pages.run_in_graphene(str(pagecount), sgx=False)
|
||||
|
||||
def time_graphene_sgx(self, pagecount):
|
||||
self.write_pages.run_in_graphene(str(pagecount), sgx=True)
|
||||
@@ -0,0 +1,3 @@
|
||||
int main() {
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/* SPDX-License-Identifier: LGPL-3.0-or-later */
|
||||
/* Copyright (c) 2020 Intel Corporation
|
||||
* Wojtek Porczyk <woju@invisiblethingslab.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
* write a number of pages to /dev/null
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void usage(char* argv0) {
|
||||
fprintf(stderr, "usage: %s PAGECOUNT\n", argv0);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
void* buf;
|
||||
size_t pagesize;
|
||||
ssize_t r;
|
||||
int fd, i, ret, pagecount;
|
||||
|
||||
if (argc != 2) {
|
||||
usage(argv[0]);
|
||||
return 2;
|
||||
}
|
||||
|
||||
errno = 0;
|
||||
pagecount = strtol(argv[1], NULL, 0);
|
||||
if (errno != 0) {
|
||||
usage(argv[0]);
|
||||
return 2;
|
||||
}
|
||||
|
||||
ret = 1;
|
||||
|
||||
pagesize = sysconf(_SC_PAGESIZE);
|
||||
|
||||
buf = mmap(NULL, pagesize, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
|
||||
if (buf == MAP_FAILED) {
|
||||
perror("mmap");
|
||||
goto err_return;
|
||||
}
|
||||
|
||||
memset(buf, 0xa5, pagesize);
|
||||
|
||||
fd = open("/dev/null", O_WRONLY);
|
||||
if (fd < 0) {
|
||||
perror("open");
|
||||
goto err_unmap;
|
||||
}
|
||||
|
||||
for (i = 0; i < pagecount; i++) {
|
||||
r = write(fd, buf, pagesize);
|
||||
if (r < 0) {
|
||||
perror("write");
|
||||
goto err_close;
|
||||
}
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
err_close:
|
||||
close(fd);
|
||||
err_unmap:
|
||||
munmap(buf, pagesize);
|
||||
err_return:
|
||||
return ret;
|
||||
}
|
||||
Reference in New Issue
Block a user