Beispiel #1
0
int main()
{
    profiling_init();

    chrono_profiler cprof;
    profiling_register_backend(cprof, "chrono");

#ifdef HAVE_VTUNE
    vtune_profiler vtprof;
    profiling_register_backend(vtprof, "vtune");
#endif

#ifdef HAVE_LIKWID
    likwid_profiler lwprof;
    profiling_register_backend(lwprof, "likwid");
#endif

    PARALLEL_REGION
    {
        profiling_init_parallel();
    }

    PARALLEL_REGION
    {
        profiling_start("print");
        std::cout << "Hello dudes, I'm gonna take a nap for a sec.\n";
        profiling_stop("print");
        profiling_start("sleep");
        system("sleep 1");
        profiling_stop("sleep");
        profiling_start("overhead");
        profiling_stop("overhead");
    }

    profiling_backend("chrono").report();
    return 0;
}
Beispiel #2
0
/* ARGSUSED */
int
os_profiling_start(perf_ctl_t *ctl, perf_task_t *task)
{
	if (perf_profiling_started()) {
		perf_status_set(PERF_STATUS_PROFILING_STARTED);
		debug_print(NULL, 2, "profiling started yet\n");
		return (0);
	}

	os_allstop();
	proc_ll_clear(NULL);

	if (profiling_start(ctl, (task_profiling_t *)(task)) != 0) {
		exit_msg_put("Fail to setup perf (probably permission denied)!\n");
		debug_print(NULL, 2, "os_profiling_start failed\n");
		perf_status_set(PERF_STATUS_PROFILING_FAILED);
		return (-1);
	}

	debug_print(NULL, 2, "os_profiling_start success\n");	
	perf_status_set(PERF_STATUS_PROFILING_STARTED);
	return (0);
}
PROCESS_THREAD(test_process, ev, data)
{
	static uint32_t time_start = 0;
	static uint32_t time_stop = 0;
	static uint32_t errors = 0;
	static uint32_t collisions = 0;
	uint32_t i = 0;
	uint32_t test_data[10] = {251284450, 371537862, 425973621, 81975339, 170405567, 225666122, 421777121, 118094495, 410814580, 414999832};

	PROCESS_BEGIN();
	PROCESS_PAUSE();

	printf("Init done, starting test using redudancy implementation %s\n", REDUNDANCE.name);

	// Initialize the profiling
	profiling_init();
	profiling_start();

	// Measure the current time
	time_start = test_precise_timestamp();

	// -----------------------------------
	// Check if no bundles are stored
	printf("Making sure list is empty\n");
	for(i=0; i<0xFFFFF; i++) {
		if( REDUNDANCE.check(i) ) {
			errors ++;
			printf("ERROR: %lu reported to be set but should be empty\n", i);
		}

		// Keep the watchdog happy
		if( i % 10 == 0 ) {
			watchdog_periodic();
		}

		if( i % 10000 == 0 ) {
			printf("\t%lu...\n", i);
		}
	}

	// -----------------------------------
	// Store 10 bundles
	printf("Storing 10 bundles...\n");
	for(i=0; i<10; i++) {
		REDUNDANCE.set(test_data[i]);

		// Keep the watchdog happy
		if( i % 5 == 0 ) {
			watchdog_periodic();
		}
	}

	// Keep the watchdog happy
	watchdog_periodic();

	// -----------------------------------
	// Retrieve the 10 bundles
	printf("Reading 10 bundles back...\n");
	for(i=0; i<10; i++) {
		if( !REDUNDANCE.check(test_data[i]) ) {
			printf("ERROR: %lu should be set but is not\n", i);
			errors++;
		} else {
			printf("\t%lu is fine\n", test_data[i]);
		}
	}

	// Keep the watchdog happy
	watchdog_periodic();

	// -----------------------------------
	// Check how many bundle ID are actually reported as set
	printf("Counting collisions...\n");
	for(i=0; i<0xFFFFF; i++) {
		if( REDUNDANCE.check(i) ) {
			printf("\tcollision at %lu\n", i);
			collisions ++;
		}

		// Keep the watchdog happy
		if( i % 10 == 0 ) {
			watchdog_periodic();
		}

		if( i % 10000 == 0 ) {
			printf("\t%lu...\n", i);
		}
	}

	printf("We have %lu collisions\n", collisions);

	// Keep the watchdog happy
	watchdog_periodic();

	// -----------------------------------
	// Now set 1000 bundle IDs and check the last 10 of them
	printf("Setting 1000 bundle IDs...\n");
	for(i=0; i<1000; i++) {
		REDUNDANCE.set(i);

		// Keep the watchdog happy
		if( i % 5 == 0 ) {
			watchdog_periodic();
		}
	}

	// Keep the watchdog happy
	watchdog_periodic();

	printf("Verifying IDs...\n");
	for(i=990; i<1000; i++) {
		if( !REDUNDANCE.check(i) ) {
			printf("ERROR: %lu should be set but is not\n", i);
			errors++;
		}

		// Keep the watchdog happy
		if( i % 5 == 0 ) {
			watchdog_periodic();
		}
	}

	printf("Done\n");

	// Measure the current time
	time_stop = test_precise_timestamp();

	watchdog_stop();
	profiling_report("redundancy", 0);

	TEST_REPORT("No of errors", errors, 1, "errors");
	TEST_REPORT("Duration", time_stop-time_start, CLOCK_SECOND, "s");
	TEST_REPORT("No of collisions", collisions, 1, "collisions");

	if( errors > 0 ) {
		TEST_FAIL("More than 1 error occurred");
	} else {
		TEST_PASS();
	}

	PROCESS_END();
}
PROCESS_THREAD(test_process, ev, data)
{
	static int n;
	static uint32_t i;
	static int errors = 0;
	static struct etimer timer;
	static uint32_t time_start, time_stop;

	PROCESS_BEGIN();

	/* Initialize the flash before the storage comes along */
	PRINTF("Intializing Flash...\n");
	BUNDLE_STORAGE.format();

	PROCESS_PAUSE();

	profiling_init();
	profiling_start();

	// Wait again
	etimer_set(&timer, CLOCK_SECOND);
	PROCESS_WAIT_UNTIL(etimer_expired(&timer));

	printf("Init done, starting test using %s storage\n", BUNDLE_STORAGE.name);

	profiling_init();
	profiling_start();

	// Measure the current time
	time_start = test_precise_timestamp();

	PRINTF("Create and Verify bundles in sequence\n");
	for(i=0; i<TEST_BUNDLES; i++) {
		PROCESS_PAUSE();

		if( my_create_bundle(i, &bundle_numbers[i], 3600) ) {
			PRINTF("\tBundle %lu created successfully \n", i);
		} else {
			PRINTF("\tBundle %lu could not be created \n", i);
			errors ++;
			continue;
		}

		if( my_verify_bundle(bundle_numbers[i], i) ) {
			PRINTF("\tBundle %lu read back successfully \n", i);
		} else {
			PRINTF("\tBundle %lu could not be read back and verified \n", i);
			errors ++;
		}
	}

	printf("Reinitialize storage\n");
	/* Reinitialize the storage and see, if the bundles persist */
	BUNDLE_STORAGE.init();

	PRINTF("Verify and Delete bundles in sequence\n");
	for(i=0; i<TEST_BUNDLES; i++) {
		if( my_verify_bundle(bundle_numbers[i], i) ) {
			PRINTF("\tBundle %lu read back successfully \n", i);
		} else {
			PRINTF("\tBundle %lu could not be read back and verified \n", i);
			errors ++;
		}

		n = BUNDLE_STORAGE.del_bundle(bundle_numbers[i], REASON_DELIVERED);

		if( n ) {
			PRINTF("\tBundle %lu deleted successfully\n", i);
		} else {
			PRINTF("\tBundle %lu could not be deleted\n", i);
			errors++;
		}
	}

	time_stop = test_precise_timestamp();

	watchdog_stop();
	profiling_report("persistent-storage", 0);

	TEST_REPORT("No of errors", errors, 1, "errors");
	TEST_REPORT("Duration", time_stop-time_start, CLOCK_SECOND, "s");

	if( errors > 0 ) {
		TEST_FAIL("More than 1 error occured");
	} else {
		TEST_PASS();
	}

	PROCESS_END();
}
Beispiel #5
0
PROCESS_THREAD(test_process, ev, data)
{
    static int n;
    static int i;
    static int errors = 0;
    static struct etimer timer;
    static uint32_t time_start, time_stop;
    uint8_t buffer[128];
    int bundle_length;
    struct mmem * bundle_original = NULL;
    struct mmem * bundle_restored = NULL;
    struct mmem * bundle_spare = NULL;
    uint32_t bundle_number;
    uint32_t bundle_number_spare;

    PROCESS_BEGIN();

    PROCESS_PAUSE();

    profiling_init();
    profiling_start();

    // Wait again
    etimer_set(&timer, CLOCK_SECOND);
    PROCESS_WAIT_UNTIL(etimer_expired(&timer));

    /* Profile initialization separately */
    profiling_stop();
    watchdog_stop();
    profiling_report("init", 0);
    watchdog_start();
    printf("Init done, starting test using %s storage\n", BUNDLE_STORAGE.name);

    profiling_init();
    profiling_start();

    // Measure the current time
    time_start = test_precise_timestamp();

    for(i=0; i<=1; i++) {
        struct mmem bla;
        if( i > 0 ) {
            mmem_alloc(&bla, 1);
        }

        printf("Serializing and deserializing bundle...\n");
        if( my_create_bundle(0, &bundle_number, 3600) ) {
            printf("\tBundle created successfully \n");
        } else {
            printf("\tBundle could not be created \n");
            errors ++;
        }

        printf("Serializing and deserializing bundle...\n");
        if( my_create_bundle(1, &bundle_number_spare, 3600) ) {
            printf("\tSpare Bundle created successfully \n");
        } else {
            printf("\tSpare Bundle could not be created \n");
            errors ++;
        }

        bundle_original = BUNDLE_STORAGE.read_bundle(bundle_number);
        if( bundle_original == NULL ) {
            printf("VERIFY: MMEM ptr is invalid\n");
            errors ++;
        }

        bundle_spare = BUNDLE_STORAGE.read_bundle(bundle_number_spare);
        if( bundle_spare == NULL ) {
            printf("VERIFY: MMEM ptr is invalid\n");
            errors ++;
        }

        // Fake timing information in the bundle to make verify successful
        struct bundle_t * bundle_original_bundle = (struct bundle_t *) MMEM_PTR(bundle_original);
        bundle_original_bundle->aeb_value_ms = 54;
        bundle_original_bundle->rec_time = clock_time();

        // Serialize the bundle
        memset(buffer, 0, 128);
        bundle_length = bundle_encode_bundle(bundle_original, buffer, 128);
        if( bundle_length < 0 ) {
            printf("SERIALIZE: fail\n");
            errors ++;
        }

        n = my_static_compare(buffer, bundle_length);
        if( n > 0 ) {
            printf("COMPARE: fail\n");
            errors += n;
        }

        // Deserialize it
        bundle_restored = bundle_recover_bundle(buffer, bundle_length);
        if( bundle_restored == NULL ) {
            printf("DESERIALIZE: unable to recover\n");
            errors ++;
        }

        n = my_compare_bundles(bundle_original, bundle_restored);
        if( n == 0 ) {
            printf("\tBundle serialized and deserialized successfully\n");
        } else {
            printf("COMPARE: differences\n");
            errors ++;
        }

        // Dellocate memory
        bundle_decrement(bundle_restored);
        bundle_restored = NULL;

        bundle_decrement(bundle_original);
        bundle_original = NULL;

        bundle_decrement(bundle_spare);
        bundle_spare = NULL;

        memset(buffer, 0, 128);

        // Delete bundle from storage
        n = BUNDLE_STORAGE.del_bundle(bundle_number, REASON_DELIVERED);
        if( n ) {
            printf("\tBundle deleted successfully\n");
        } else {
            printf("\tBundle could not be deleted\n");
            errors++;
        }


        printf("Comparing static bundle...\n");
        if( my_create_bundle(0, &bundle_number, 3600) ) {
            printf("\tReference Bundle created successfully \n");
        } else {
            printf("\ttReference Bundle could not be created \n");
            errors ++;
        }

        bundle_original = BUNDLE_STORAGE.read_bundle(bundle_number);
        if( bundle_original == NULL ) {
            printf("VERIFY: MMEM ptr is invalid\n");
            errors ++;
        }

        // Deserialize it
        bundle_restored = bundle_recover_bundle(static_compare_bundle, sizeof(static_compare_bundle));
        if( bundle_restored == NULL ) {
            printf("DESERIALIZE: unable to recover static bundle\n");
            errors ++;
        }

        // Deserialize it one more time
        bundle_spare = bundle_recover_bundle(static_compare_bundle, sizeof(static_compare_bundle));
        if( bundle_spare == NULL ) {
            printf("DESERIALIZE: unable to recover static bundle\n");
            errors ++;
        }

        n = my_compare_bundles(bundle_original, bundle_restored);
        if( n == 0 ) {
            printf("\tStatic Bundle verified successfully\n");
        } else {
            printf("COMPARE: differences\n");
            errors ++;
        }

        n = my_compare_bundles(bundle_original, bundle_spare);
        if( n == 0 ) {
            printf("\tStatic Bundle verified successfully\n");
        } else {
            printf("COMPARE: differences\n");
            errors ++;
        }

        // Dellocate memory
        bundle_decrement(bundle_restored);
        bundle_restored = NULL;

        bundle_decrement(bundle_original);
        bundle_original = NULL;

        bundle_decrement(bundle_spare);
        bundle_spare = NULL;
    }

    time_stop = test_precise_timestamp();

    watchdog_stop();
    profiling_report("serializer", 0);

    TEST_REPORT("No of errors", errors, 1, "errors");
    TEST_REPORT("Duration", time_stop-time_start, CLOCK_SECOND, "s");

    if( errors > 0 ) {
        TEST_FAIL("More than 0 errors occured");
    } else {
        TEST_PASS();
    }

    PROCESS_END();
}