mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-06 09:21:49 +00:00
parent
9097c80269
commit
0451d3bbed
49
repos/os/run/cache.run
Normal file
49
repos/os/run/cache.run
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
#
|
||||||
|
# \brief Simple cache benchmark
|
||||||
|
# \author Johannes Schlatow
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
set build_components { core init test/cache }
|
||||||
|
|
||||||
|
lappend_if [have_spec arndale] build_components drivers/platform
|
||||||
|
|
||||||
|
build $build_components
|
||||||
|
|
||||||
|
create_boot_directory
|
||||||
|
|
||||||
|
set config {
|
||||||
|
<config>
|
||||||
|
<parent-provides>
|
||||||
|
<service name="LOG"/>
|
||||||
|
<service name="CPU"/>
|
||||||
|
<service name="PD"/>
|
||||||
|
<service name="ROM"/>
|
||||||
|
<service name="IO_MEM"/>
|
||||||
|
</parent-provides>
|
||||||
|
<default-route>
|
||||||
|
<any-service> <parent/> </any-service>
|
||||||
|
</default-route>
|
||||||
|
<default caps="100"/>}
|
||||||
|
|
||||||
|
append_if [have_spec arndale] config {
|
||||||
|
<start name="platform_drv">
|
||||||
|
<resource name="RAM" quantum="1M"/>
|
||||||
|
<provides><service name="Regulator"/></provides>
|
||||||
|
</start> }
|
||||||
|
|
||||||
|
append config {
|
||||||
|
<start name="test-cache">
|
||||||
|
<resource name="RAM" quantum="64M"/>
|
||||||
|
</start>
|
||||||
|
</config> }
|
||||||
|
|
||||||
|
install_config $config
|
||||||
|
|
||||||
|
set boot_modules { core ld.lib.so init test-cache }
|
||||||
|
|
||||||
|
lappend_if [have_spec arndale] boot_modules platform_drv
|
||||||
|
|
||||||
|
build_boot_image $boot_modules
|
||||||
|
|
||||||
|
run_genode_until "done.*\n" 300
|
107
repos/os/src/test/cache/main.cc
vendored
Normal file
107
repos/os/src/test/cache/main.cc
vendored
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
/*
|
||||||
|
* \brief Test for cache performance
|
||||||
|
* \author Johannes Schlatow
|
||||||
|
* \date 2019-05-02
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2019 Genode Labs GmbH
|
||||||
|
*
|
||||||
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
|
* under the terms of the GNU Affero General Public License version 3.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Genode includes */
|
||||||
|
#include <base/log.h>
|
||||||
|
#include <base/component.h>
|
||||||
|
#include <base/heap.h>
|
||||||
|
#include <trace/timestamp.h>
|
||||||
|
|
||||||
|
using namespace Genode::Trace;
|
||||||
|
|
||||||
|
class Test
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
Genode::Heap &_alloc;
|
||||||
|
Genode::size_t _size;
|
||||||
|
|
||||||
|
unsigned *_data { 0 };
|
||||||
|
|
||||||
|
Timestamp ts_to_time(Timestamp start, Timestamp end)
|
||||||
|
{
|
||||||
|
Timestamp diff = end - start;
|
||||||
|
if (end < start) diff--;
|
||||||
|
|
||||||
|
return diff;
|
||||||
|
}
|
||||||
|
|
||||||
|
Test(const Test &);
|
||||||
|
void operator=(const Test&);
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
Test(Genode::Heap &alloc, Genode::size_t size_bytes)
|
||||||
|
: _alloc(alloc),
|
||||||
|
_size(size_bytes/sizeof(unsigned))
|
||||||
|
{
|
||||||
|
_data = new (_alloc) unsigned[_size];
|
||||||
|
}
|
||||||
|
|
||||||
|
~Test()
|
||||||
|
{
|
||||||
|
destroy(_alloc, _data);
|
||||||
|
}
|
||||||
|
|
||||||
|
Timestamp read_write(unsigned iterations=100)
|
||||||
|
{
|
||||||
|
Timestamp start_ts = timestamp();
|
||||||
|
|
||||||
|
for (Genode::size_t i=0; i < iterations; i++) {
|
||||||
|
for (Genode::size_t index=0; index < _size; index++) {
|
||||||
|
_data[index]++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ts_to_time(start_ts, timestamp()) / iterations;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Main
|
||||||
|
{
|
||||||
|
Genode::Env &env;
|
||||||
|
|
||||||
|
Genode::Heap heap { env.ram(), env.rm() };
|
||||||
|
|
||||||
|
Main(Genode::Env &env);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Main::Main(Genode::Env &env) : env(env)
|
||||||
|
{
|
||||||
|
using namespace Genode;
|
||||||
|
|
||||||
|
log("--- test-cache started ---");
|
||||||
|
|
||||||
|
enum {
|
||||||
|
START_SIZE = 8,
|
||||||
|
END_SIZE = 1024 * 4,
|
||||||
|
THRESHOLD_PERCENT = 10,
|
||||||
|
};
|
||||||
|
|
||||||
|
size_t size = START_SIZE;
|
||||||
|
while (size <= END_SIZE)
|
||||||
|
{
|
||||||
|
log("\n--- Running tests for size ", size, "KB ---");
|
||||||
|
|
||||||
|
Test test(heap, size*1024);
|
||||||
|
log("Read/write: ", test.read_write() / size, " cycles on average per KB");
|
||||||
|
|
||||||
|
size = size << 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
log("--- test-cache done ---");
|
||||||
|
}
|
||||||
|
|
||||||
|
void Component::construct(Genode::Env &env) { static Main inst(env); }
|
||||||
|
Genode::size_t Component::stack_size() { return 32*1024*sizeof(long); }
|
||||||
|
|
3
repos/os/src/test/cache/target.mk
vendored
Normal file
3
repos/os/src/test/cache/target.mk
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
TARGET = test-cache
|
||||||
|
SRC_CC = main.cc
|
||||||
|
LIBS = base
|
Loading…
x
Reference in New Issue
Block a user