/*
 * Copyright 2016, Anton Blanchard, Michael Ellerman, IBM Corp.
 * Licensed under GPLv2.
 */

#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <time.h>

#include "utils.h"

#define ITERATIONS 5000000

#define MEMSIZE (128 * 1024 * 1024)

int test_mmap(void)
{
	struct timespec ts_start, ts_end;
	unsigned long i = ITERATIONS;

	clock_gettime(CLOCK_MONOTONIC, &ts_start);

	while (i--) {
		char *c = mmap(NULL, MEMSIZE, PROT_READ|PROT_WRITE,
			       MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
		FAIL_IF(c == MAP_FAILED);
		munmap(c, MEMSIZE);
	}

	clock_gettime(CLOCK_MONOTONIC, &ts_end);

	printf("time = %.6f\n", ts_end.tv_sec - ts_start.tv_sec + (ts_end.tv_nsec - ts_start.tv_nsec) / 1e9);

	return 0;
}

int main(void)
{
	return test_harness(test_mmap, "mmap_bench");
}
git/'>net-next.git</a></td><td class='form'><form method='get'>
<input type='hidden' name='id' value='69973b830859bc6529a7a0468ba0d80ee5117826'/><select name='h' onchange='this.form.submit();'>
<option value='emaclite-cleanup'>emaclite-cleanup</option>
<option value='master' selected='selected'>master</option>
<option value='nds-private-remove'>nds-private-remove</option>
<option value='packet-loop-back'>packet-loop-back</option>
<option value='packet-rx-pump-back'>packet-rx-pump-back</option>
</select> <input type='submit' value='switch'/></form></td></tr>
<tr><td class='sub'>net-next plumbings</td><td class='sub right'>Tobias Klauser</td></tr></table>
<table class='tabs'><tr><td>
<a href='/cgit.cgi/linux/net-next.git/'>summary</a><a href='/cgit.cgi/linux/net-next.git/refs/?id=69973b830859bc6529a7a0468ba0d80ee5117826'>refs</a><a href='/cgit.cgi/linux/net-next.git/log/drivers/usb/phy/phy-am335x.c'>log</a><a href='/cgit.cgi/linux/net-next.git/tree/drivers/usb/phy/phy-am335x.c?id=69973b830859bc6529a7a0468ba0d80ee5117826'>tree</a><a class='active' href='/cgit.cgi/linux/net-next.git/commit/drivers/usb/phy/phy-am335x.c?id=69973b830859bc6529a7a0468ba0d80ee5117826'>commit</a><a href='/cgit.cgi/linux/net-next.git/diff/drivers/usb/phy/phy-am335x.c?id=69973b830859bc6529a7a0468ba0d80ee5117826'>diff</a></td><td class='form'><form class='right' method='get' action='/cgit.cgi/linux/net-next.git/log/drivers/usb/phy/phy-am335x.c'>
<input type='hidden' name='id' value='69973b830859bc6529a7a0468ba0d80ee5117826'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/cgit.cgi/linux/net-next.git/commit/?id=69973b830859bc6529a7a0468ba0d80ee5117826'>root</a>/<a href='/cgit.cgi/linux/net-next.git/commit/drivers?id=69973b830859bc6529a7a0468ba0d80ee5117826'>drivers</a>/<a href='/cgit.cgi/linux/net-next.git/commit/drivers/usb?id=69973b830859bc6529a7a0468ba0d80ee5117826'>usb</a>/<a href='/cgit.cgi/linux/net-next.git/commit/drivers/usb/phy?id=69973b830859bc6529a7a0468ba0d80ee5117826'>phy</a>/<a href='/cgit.cgi/linux/net-next.git/commit/drivers/usb/phy/phy-am335x.c?id=69973b830859bc6529a7a0468ba0d80ee5117826'>phy-am335x.c</a></div><div class='content'><div class='cgit-panel'><b>diff options</b><form method='get'><input type='hidden' name='id' value='69973b830859bc6529a7a0468ba0d80ee5117826'/><table><tr><td colspan='2'/></tr><tr><td class='label'>context:</td><td class='ctrl'><select name='context' onchange='this.form.submit();'><option value='1'>1</option><option value='2'>2</option><option value='3' selected='selected'>3</option><option value='4'>4</option><option value='5'>5</option><option value='6'>6</option><option value='7'>7</option><option value='8'>8</option><option value='9'>9</option><option value='10'>10</option><option value='15'>15</option><option value='20'>20</option><option value='25'>25</option><option value='30'>30</option><option value='35'>35</option><option value='40'>40</option></select></td></tr><tr><td class='label'>space:</td><td class='ctrl'><select name='ignorews' onchange='this.form.submit();'><option value='0' selected='selected'>include</option><option value='1'>ignore</option></select></td></tr><tr><td class='label'>mode:</td><td class='ctrl'><select name='dt' onchange='this.form.submit();'><option value='0' selected='selected'>unified</option><option value='1'>ssdiff</option><option value='2'>stat only</option></select></td></tr><tr><td/><td class='ctrl'><noscript><input type='submit' value='reload'/></noscript></td></tr></table></form></div><table summary='commit info' class='commit-info'>
<tr><th>author</th><td>Linus Torvalds &lt;torvalds@linux-foundation.org&gt;</td><td class='right'>2016-12-11 11:17:54 -0800</td></tr>
<tr><th>committer</th><td>Linus Torvalds &lt;torvalds@linux-foundation.org&gt;</td><td class='right'>2016-12-11 11:17:54 -0800</td></tr>
<tr><th>commit</th><td colspan='2' class='oid'><a href='/cgit.cgi/linux/net-next.git/commit/drivers/usb/phy/phy-am335x.c?id=69973b830859bc6529a7a0468ba0d80ee5117826'>69973b830859bc6529a7a0468ba0d80ee5117826</a> (<a href='/cgit.cgi/linux/net-next.git/patch/drivers/usb/phy/phy-am335x.c?id=69973b830859bc6529a7a0468ba0d80ee5117826'>patch</a>)</td></tr>
<tr><th>tree</th><td colspan='2' class='oid'><a href='/cgit.cgi/linux/net-next.git/tree/?id=69973b830859bc6529a7a0468ba0d80ee5117826'>5f11fe15ed9d9a3ab9c92242030e54b73ecdce45</a> /<a href='/cgit.cgi/linux/net-next.git/tree/drivers/usb/phy/phy-am335x.c?id=69973b830859bc6529a7a0468ba0d80ee5117826'>drivers/usb/phy/phy-am335x.c</a></td></tr>
<tr><th>parent</th><td colspan='2' class='oid'><a href='/cgit.cgi/linux/net-next.git/commit/drivers/usb/phy/phy-am335x.c?id=2e4333c14de06a333783d6812cf3c4998f78b0c8'>2e4333c14de06a333783d6812cf3c4998f78b0c8</a> (<a href='/cgit.cgi/linux/net-next.git/diff/drivers/usb/phy/phy-am335x.c?id=69973b830859bc6529a7a0468ba0d80ee5117826&amp;id2=2e4333c14de06a333783d6812cf3c4998f78b0c8'>diff</a>)</td></tr></table>
<div class='commit-subject'>Linux 4.9</div><div class='commit-msg'></div><div class='diffstat-header'><a href='/cgit.cgi/linux/net-next.git/diff/?id=69973b830859bc6529a7a0468ba0d80ee5117826'>Diffstat</a> (limited to 'drivers/usb/phy/phy-am335x.c')</div><table summary='diffstat' class='diffstat'>