議論/メッセージ/CR3切替コスト/調査2のコード


Top / 議論 / メッセージ / CR3切替コスト / 調査2のコード

コード

disableInterrupt();
 
dword total;
int count;
 
total = 0;
count = 0;
 
for (int i = 0; i < 500; i++)
{
    /* at first flush all */
    g_page_manager->setPageDirectory(cr31);
    g_page_manager->setPageDirectory(cr32);
 
    dword l1, l2, h1, h2;
 
    dword* p = (dword*)0x600000;
 
    /* read and create cache */
    volatile dword test1 = *p;
 
    rdtsc(&l1, &h1);
 
    /* read once using cache */
    volatile dword test2 = *p;
 
    rdtsc(&l2, &h2);
 
    if (h1 != h2) continue;
 
    count++;
    total += (l2 - l1);
}
 
g_console->printf("read using cache: %d\n", total / count);
 
total = 0;
count = 0;
 
for (int i = 0; i < 500; i++)
{
    /* at first flush all */
    g_page_manager->setPageDirectory(cr31);
    g_page_manager->setPageDirectory(cr32);
 
    dword l1, l2, h1, h2;
 
    dword* p = (dword*)0x600000;
 
    /* read and create cache */
    volatile dword test1 = *p;
 
    rdtsc(&l1, &h1);
 
    asm volatile ("invlpg %0\n": "=m"(p));
 
    rdtsc(&l2, &h2);
 
    if (h1 != h2) continue;
 
    count++;
    total += (l2 - l1);
}
 
g_console->printf("invlpg: %d\n", total / count);
 
total = 0;
count = 0;
 
for (int i = 0; i < 500; i++)
{
    /* at first flush all */
    g_page_manager->setPageDirectory(cr31);
    g_page_manager->setPageDirectory(cr32);
 
    dword l1, l2, h1, h2;
 
    dword* p = (dword*)0x600000;
 
    /* read and create cache */
    volatile dword test1 = *p;
 
    asm volatile ("invlpg %0\n": "=m"(p));
 
    rdtsc(&l1, &h1);
 
    /* read once */
    volatile dword test2 = *p;
 
    rdtsc(&l2, &h2);
 
    if (h1 != h2) continue;
 
    count++;
    total += (l2 - l1);
}
 
g_console->printf("create cache and read: %d\n", total / count);
 
total = 0;
count = 0;
 
for (int i = 0; i < 500; i++)
{
    /* at first flush all */
    g_page_manager->setPageDirectory(cr31);
    g_page_manager->setPageDirectory(cr32);
 
    dword l1, l2, h1, h2;
 
    dword* p = (dword*)0x600000;
 
    /* read and create cache */
    volatile dword test1 = *p;
 
    rdtsc(&l1, &h1);
 
    for (int j = 0; j < 10000; j++)
    {
        j++;
        j--;
    }
 
    rdtsc(&l2, &h2);
 
    if (h1 != h2) continue;
 
    count++;
    total += (l2 - l1);
}
 
g_console->printf("loop: %d\n", total / count);

MENU

now: 3

リンク


最新の20件
2018-10-07 2018-09-20 2018-09-03 2018-05-09 2017-09-29 2017-01-10 2016-12-11 2016-10-04 2016-08-14 2016-05-29 2015-12-28 2013-02-25 2013-02-21 2013-02-20 2013-02-12 2013-02-11 2013-02-10
最新の20件
2010-02-01 2010-01-31 2010-01-30 2010-01-29 2010-01-16

Counter: 2026, today: 1, yesterday: 0

リロード   新規 編集 凍結 差分 添付 複製 改名   トップ 一覧 検索 最終更新 バックアップ   ヘルプ   最終更新のRSS

Last-modified: 2008-03-28 (金) 15:48:02 (3857d);  Modified by mona
PukiWiki 1.4.6 Copyright © 2001-2005 PukiWiki Developers Team. License is GPL.
Based on "PukiWiki" 1.3 by yu-ji
Powered by PHP 5.2.17
HTML convert time to 0.034 sec.