int _tmain(int argc, _TCHAR* argv[])
{
	_lock = new spin_lock();	
	_posted.store(0);
	_iocp = CreateIoCompletionPort( INVALID_HANDLE_VALUE , NULL , NULL , 0 );

	std::cout << "start" << std::endl;
	std::chrono::time_point<std::chrono::system_clock> start, end;
	std::chrono::duration<double> elapsed_seconds;

	start = std::chrono::system_clock::now();    

	process_1();
	
	end = std::chrono::system_clock::now();
 
    elapsed_seconds = end-start;
    std::cout << "elapsed time: " << elapsed_seconds.count() << "s\n";
	start = std::chrono::system_clock::now();    

	process_0();

	end = std::chrono::system_clock::now(); 
    elapsed_seconds = end-start;
    std::cout << "elapsed time: " << elapsed_seconds.count() << "s\n";

	return 0;
}
/*-----------------------------------------------------
 * 10の位を文字へ
 *---------------------------------------------------*/
static char *process_10(int8_t num, int *p_flag, char *p_str)
{
    int    divide_10    = (int)(num / 10);
    int8_t remainder_10 = num % 10;
    char   val          = ASCII_NUMBER_0;
    int    i;
    
    for(i = 0; i < divide_10; i++)
    {
        val++;
    }
    
    p_str[*p_flag] = val;
    (*p_flag)++;
    
    return process_1(remainder_10, p_flag, p_str);
}
示例#3
0
/*=====================================================
 * @brief
 *     char型の数値を文字列へ変換
 * @param
 *     num:変換したい数値
 * @return
 *     str:変換した文字列を格納した配列へのポインタ
 * @note
 *     -128 ~ 127の数値
 *===================================================*/
char *char_number_to_string(char num)
{
    static char str[5];
    int  flag = 0;
    char *p_error_message = "size of number is over";

    /* num == -128 process */
    if(num == INT8_T_MINIMUM)
    {
        str[0] = '-';
        str[1] = '1';
        str[2] = '2';
        str[3] = '8';
        str[4] = '\0';
        
        return str;
    }
   
    /* For negetive number process */
    if(num < 0)
    {
        str[flag] = '-';
        flag++;
        num *= (-1);
    }

    /* converting process */
    if(MIN_100 <= num && num <= MAX_100)
    {
        return process_100(num, &flag, str);
    }
    else if(MIN_10 <= num && num <= MAX_10)
    {
        return process_10(num, &flag, str);
    }
    else if(MIN_1 <= num && num <= MAX_1)
    {
        return process_1(num, &flag, str);
    }
    else
    {
        return p_error_message;
    }

}