/** * @file srcMaxParamListInFunction.cpp * experiment: how many parameter in max on function ? */ #include "stdafx.h"//empty file~ #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. #endif #include <windows.h> #include <stdio.h> #include <tchar.h> /** 验证在c++中, 函数列表最大个数 */ int fnTestMin(); int fnTest(INT p1, INT p2, INT p3, INT p4, INT p5, INT p6, INT p7, INT p8, INT p9, INT p10, INT p11, INT p12, INT p13, INT p14, INT p15, INT p16, INT p17, INT p18, INT p19, INT p20, INT p21, INT p22, INT p23, INT p24, INT p25, INT p26, INT p27, INT p28, INT p29, INT p30, INT p31, INT p32); int _tmain(int argc, _TCHAR* argv[]) { DWORD dwTickBegin = 0; DWORD dwTickEND = 0; dwTickBegin = GetTickCount(); fnTest(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16, 17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32); dwTickEND = GetTickCount(); _tprintf(_T("Trash Function use Tick is: %d\n"), dwTickEND - dwTickBegin); dwTickBegin = GetTickCount(); fnTestMin(); dwTickEND = GetTickCount(); _tprintf(_T("normal Function use Tick is: %d\n"), dwTickEND - dwTickBegin); /** * run result who would like input so mach parameter~ Trash Function use Tick is: 0 tiny parameter list in is better normal Function use Tick is: 0 */ /** * @note 不知道c++的参数最多可以输入多少个, * 为了动态调用DLL, 看到 LateLoad.h 中最多定义了9个参数的宏,实际应用中足够了 * 也看到实际工程中,有个同事写了12个参数的函数~ * 想确定在c++中函数入参列表个数的最大值, 晕, 没实验出来 * 垃圾函数和普通函数的执行时间差不多, 参数列表个数对性能没有影响 */ getchar(); return 0; } int fnTest(INT p1, INT p2, INT p3, INT p4, INT p5, INT p6, INT p7, INT p8, INT p9, INT p10, INT p11, INT p12, INT p13, INT p14, INT p15, INT p16, INT p17, INT p18, INT p19, INT p20, INT p21, INT p22, INT p23, INT p24, INT p25, INT p26, INT p27, INT p28, INT p29, INT p30, INT p31, INT p32) { _tprintf(_T("who would like input so mach parameter~\n")); return S_OK; } int fnTestMin() { _tprintf(_T("tiny parameter list in is better\n")); return S_OK; }