Ejemplo n.º 1
0
/*
 * this function calls the others and returns all the results in a struct
 * containing all the data we are interested in, comparing the various times
 */
timeMeasurmentStructure measureTimes(unsigned int osm_iterations)
{
	timeMeasurmentStructure allData;
	if(gethostname(allData.machineName,HOST_NAME_MAX) == FAILURE)
	{
		allData.machineName[0] = END_OF_STR;
	}
	allData.numberOfIterations = (osm_iterations / LP_UNRLNG + (osm_iterations % LP_UNRLNG ? 1 : 0)) * LP_UNRLNG;
	allData.functionTimeNanoSecond = osm_function_time(osm_iterations);
	allData.instructionTimeNanoSecond = osm_operation_time(osm_iterations);
	allData.trapTimeNanoSecond = osm_syscall_time(osm_iterations);
	//check if any error occurred during time measurement, and if so, the ratio is '-1'
	int funcRatio = FAILURE, trapRatio = FAILURE;
	if(allData.instructionTimeNanoSecond != FAILURE)
	{
		if(allData.functionTimeNanoSecond != FAILURE)
		{
			funcRatio = allData.functionTimeNanoSecond / allData.instructionTimeNanoSecond;
		}
		if(allData.trapTimeNanoSecond != FAILURE)
		{
			trapRatio = allData.trapTimeNanoSecond / allData.instructionTimeNanoSecond;
		}
	}
	allData.functionInstructionRatio = funcRatio;
	allData.trapInstructionRatio = trapRatio;
	return allData;
}
Ejemplo n.º 2
0
/* Time measurement function for all operations.
 * returns a struct containing all the measures.
 * on any calculation error the value will be -1.
 * on any error in the machine name, the value will be NULL.
 * The machineName field in the returned struct is dynamically allocated and
 * it is the user responsibility to free the memory.
 */ 
timeMeasurmentStructure measureTimes (unsigned int operation_iterations,
                                        unsigned int function_iterations,
        				unsigned int syscall_iterations,
            				unsigned int disk_iterations)
{   
    timeMeasurmentStructure measures;
    measures.machineName = new char;
    if(gethostname(measures.machineName, MAX_MACHINE_NAME_LEN) == -1) {
        measures.machineName = NULL;
    }
    measures.instructionTimeNanoSecond = 
                                osm_operation_time(operation_iterations);
    measures.functionTimeNanoSecond = osm_function_time(function_iterations);
    measures.trapTimeNanoSecond = osm_syscall_time(syscall_iterations);
    measures.diskTimeNanoSecond = osm_disk_time(disk_iterations);
    if (measures.instructionTimeNanoSecond == 0){
		measures.functionInstructionRatio = -1;
		measures.trapInstructionRatio = -1;
		measures.diskInstructionRatio = -1;
	}
	else {
		measures.functionInstructionRatio = measures.functionTimeNanoSecond / 
										measures.instructionTimeNanoSecond;
		measures.trapInstructionRatio = measures.trapTimeNanoSecond / 
										measures.instructionTimeNanoSecond;
		measures.diskInstructionRatio = measures.diskTimeNanoSecond / 
										measures.instructionTimeNanoSecond;
	}
    return measures;
};