コード例 #1
0
ファイル: kvmclock_test.c プロジェクト: copy/v86
int main(int ac, char **av)
{
        int nerr = 0;
        int ncpus;
        int i;

        if (ac > 1)
                loops = atol(av[1]);
        if (ac > 2)
                sec = atol(av[2]);
        if (ac > 3)
                threshold = atol(av[3]);

        smp_init();

        ncpus = cpu_count();
        if (ncpus > MAX_CPU)
                ncpus = MAX_CPU;
        for (i = 0; i < ncpus; ++i)
                on_cpu(i, kvm_clock_init, (void *)0);

        if (ac > 2) {
                printf("Wallclock test, threshold %ld\n", threshold);
                printf("Seconds get from host:     %ld\n", sec);
                for (i = 0; i < ncpus; ++i)
                        on_cpu(i, wallclock_test, &nerr);
        }

        printf("Check the stability of raw cycle ...\n");
        pvclock_set_flags(PVCLOCK_TSC_STABLE_BIT
                          | PVCLOCK_RAW_CYCLE_BIT);
        if (cycle_test(ncpus, 1, &ti[0]))
                printf("Raw cycle is not stable\n");
        else
                printf("Raw cycle is stable\n");

        pvclock_set_flags(PVCLOCK_TSC_STABLE_BIT);
        printf("Monotonic cycle test:\n");
        nerr += cycle_test(ncpus, 1, &ti[1]);

        printf("Measure the performance of raw cycle ...\n");
        pvclock_set_flags(PVCLOCK_TSC_STABLE_BIT
                          | PVCLOCK_RAW_CYCLE_BIT);
        cycle_test(ncpus, 0, &ti[2]);

        printf("Measure the performance of adjusted cycle ...\n");
        pvclock_set_flags(PVCLOCK_TSC_STABLE_BIT);
        cycle_test(ncpus, 0, &ti[3]);

        for (i = 0; i < ncpus; ++i)
                on_cpu(i, kvm_clock_clear, (void *)0);

        return nerr > 0 ? 1 : 0;
}
コード例 #2
0
int main(int ac, char **av)
{
        int ncpus;
        int nerr = 0, i;
        long loops = DEFAULT_TEST_LOOPS;
        long sec = 0;
        long threshold = DEFAULT_THRESHOLD;

        if (ac > 1)
                loops = atol(av[1]);
        if (ac > 2)
                sec = atol(av[2]);
        if (ac > 3)
                threshold = atol(av[3]);

        smp_init();

        ncpus = cpu_count();
        if (ncpus > MAX_CPU)
                ncpus = MAX_CPU;
        for (i = 0; i < ncpus; ++i)
                on_cpu(i, kvm_clock_init, (void *)0);

        if (ac > 2)
                nerr += wallclock_test(sec, threshold);

        printf("Check the stability of raw cycle ...\n");
        pvclock_set_flags(PVCLOCK_TSC_STABLE_BIT
                          | PVCLOCK_RAW_CYCLE_BIT);
        if (cycle_test(ncpus, loops, 1, &ti[0]))
                printf("Raw cycle is not stable\n");
        else
                printf("Raw cycle is stable\n");

        pvclock_set_flags(PVCLOCK_TSC_STABLE_BIT);
        printf("Monotonic cycle test:\n");
        nerr += cycle_test(ncpus, loops, 1, &ti[1]);

        printf("Measure the performance of raw cycle ...\n");
        pvclock_set_flags(PVCLOCK_TSC_STABLE_BIT
                          | PVCLOCK_RAW_CYCLE_BIT);
        cycle_test(ncpus, loops, 0, &ti[2]);

        printf("Measure the performance of adjusted cycle ...\n");
        pvclock_set_flags(PVCLOCK_TSC_STABLE_BIT);
        cycle_test(ncpus, loops, 0, &ti[3]);

        for (i = 0; i < ncpus; ++i)
                on_cpu(i, kvm_clock_clear, (void *)0);

        return nerr > 0 ? 1 : 0;
}