当前位置: 首页>>代码示例>>C++>>正文


C++ std::clock方法代码示例

本文整理汇总了C++中std::clock方法的典型用法代码示例。如果您正苦于以下问题:C++ std::clock方法的具体用法?C++ std::clock怎么用?C++ std::clock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在std的用法示例。


在下文中一共展示了std::clock方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main()
{
	using std::clock; 

	ShowWindow(GetConsoleWindow(), SW_MAXIMIZE);

	auto timeStart(clock());
	const MidiParser_Facade midi("../../../Test.mid");
	auto runDuration(clock() - timeStart);

	timeStart = clock();
	for (auto iter(midi.GetNotes().cbegin()); iter != midi.GetNotes().cend(); ++iter)
	{
		printf("TRACK #%d of %u\n", static_cast<int>(iter - midi.GetNotes().cbegin() + 1),
			static_cast<unsigned>(midi.GetNotes().size()));
		for (auto jiter(iter->cbegin()); jiter != iter->cend(); ++jiter)
		{
			printf("Time %u Note %d\t", midi.GetMilliSeconds()
				.at(static_cast<size_t>(iter - midi.GetNotes().cbegin()))
				.at(static_cast<size_t>(jiter - iter->cbegin())),
				*jiter);
		}
		printf("\nEND OF TRACK #%d of %u\n\n", static_cast<int>(iter - midi.GetNotes().cbegin() + 1),
			static_cast<unsigned>(midi.GetNotes().size()));
	}
	puts("===================\nEND OF ALL TRACKS\n===================");
	const auto printDuration(clock() - timeStart);
	printf("\nRun time = %f seconds\tPrint time = %f seconds\nTotal time = %f seconds\n",
		static_cast<float>(runDuration) / CLOCKS_PER_SEC, static_cast<float>(printDuration) / CLOCKS_PER_SEC,
		static_cast<float>(runDuration + printDuration) / CLOCKS_PER_SEC);

	printf("\n\n%s", midi.GetLog().c_str());
}
开发者ID:BShakhovsky,项目名称:MidiParser_Unused,代码行数:33,代码来源:TestRun.cpp

示例2: main

int main(int argc, char** argv) {
	list<int> test1 = list<int>();
	list<int> test2 = list<int>();

	init(test1);
	init(test2);

	cout << "Done initializing...\n";

	// print(test1);
	// print(test2);

	// clock_t startTime = clock();
	// list<int> list3 = nSquaredDifference(test1, test2);
	// clock_t runTime = clock() - startTime;
	// cout << "n^2 runtime: " << ((float) runTime) / CLOCKS_PER_SEC << "\n";
	
	//print(list3);

	// clock_t startTime = clock();
	// list<int> list4 = nLogNDifference(test1, test2);
	// clock_t runTime = clock() - startTime;
	// cout << "nlogn runtime: " << ((float) runTime) / CLOCKS_PER_SEC << "\n";
	
	// print(list4);

	clock_t startTime = clock();
	list<int> list5 = nDifference(test1, test2);
	clock_t runTime = clock() - startTime;
	cout << "n runtime: " << ((float) runTime) / CLOCKS_PER_SEC << "\n";
	// print(list5);
}
开发者ID:wclausen,项目名称:ProgrammingPraxis,代码行数:32,代码来源:11_20_12.cpp

示例3: main

int main(int argc, char **argv)
{
    progname = argv[0];
    if (argc < 5)
    {
        usage();
    }

    clock_t start = clock();
    WholeGenomeAlignment wga(argv[2], GetAlignmentBlockStorage(argv[4]));

    {
        set<string> filter;
        filter.insert(argv[2]);
        for (int i = 5; i < argc; ++i)
        {
            filter.insert(argv[i]);
        }

        BitSequenceFactory * factory = GetSequenceFactory(argv[3]);

        if (filter.size() > 1)
        {
            ReadMafFile(argv[1], wga, *factory, &filter);
        }
        else
        {
            ReadMafFile(argv[1], wga, *factory);
        }

        delete factory;
    }
    clock_t end = clock();
    cerr.precision(10);
    cerr << "Parsed MAF in " << clock_to_sec(end - start) <<
            " seconds." << endl;

    size_t reference_size = wga.getReferenceSize();

    while (1)
    {
        size_t position = rand() % reference_size;
        try
        {
            WholeGenomeAlignment::PositionMapping *mapping;
            mapping = wga.mapPositionToAll(position);
            if (mapping->begin() == mapping->end())
            {
                delete mapping;
                throw OutOfSequence();
            }
            cout << mapping->begin()->first << "\t" << position << endl;
            delete mapping;
        }
        catch (OutOfSequence &e)
        { }
    }
}
开发者ID:koniiiik,项目名称:libmultialn,代码行数:58,代码来源:generate_random_positions.cpp

示例4: main

int main(int argc, char **argv)
{
	glutInit(&argc,argv);
	int t;
	double time;
	int iterations = 250;

	//cin >> iterations;
	//if(argc == 2)
		cout << "success? " << (timeBeginPeriod(1)==TIMERR_NOERROR) << endl;

	LARGE_INTEGER clockFrequency;
	QueryPerformanceFrequency(&clockFrequency);
	cout << "f = " << clockFrequency.QuadPart << " Hz" << endl;
	cout << "T = " << 1000.0/clockFrequency.QuadPart << " ms" << endl;

	LARGE_INTEGER start,stop;
	QueryPerformanceCounter(&start);
	for(int c = 0 ; c < iterations ; c++)
		;
	QueryPerformanceCounter(&stop);
	cout << stop.QuadPart-start.QuadPart << endl;

	time = CPUclock::currentTime();
	for(int c = 0 ; c < iterations ; c++)
		;
	cout << CPUclock::currentTime()-time << endl;

	t = timeGetTime();
	for(int c = 0 ; c < iterations ; c++)
		cout << '.';
	cout << timeGetTime()-t << endl;

	t = clock();
	for(int c = 0 ; c < iterations ; c++)
		cout << '.';
	cout << clock()-t << endl;

	t = glutGet(GLUT_ELAPSED_TIME);
	for(int c = 0 ; c < iterations ; c++)
		cout << '.';
	cout << glutGet(GLUT_ELAPSED_TIME)-t << endl;

	//if(argc == 2)
		timeEndPeriod(1);
	system("PAUSE");
	return 0;
} // end function main
开发者ID:nomad-,项目名称:time-functions--performance,代码行数:48,代码来源:main.cpp

示例5: main

int main()
{
  cout << clock() << '\n';
  try
  {
    f(0);
  }
  catch(myErr)
  {
  }
  cout << clock() << '\n';
  try
  {
    f(1);
  }
  catch(myErr)
  {
  }
  cout << clock() << '\n';

 
}
开发者ID:bugrimov,项目名称:straustrup,代码行数:22,代码来源:8-08.cpp

示例6: main

int main(int argc, char** argv) {
	list<int> list1;
	list<int> list2;
	clock_t startTime;

	init(list1);
	init(list2);

	// print(list1);
	// print(list2);
	startTime = clock();
	list<int> list3 = nSquaredUnion(list1, list2);
	// print(list3);
	cout << "Time for n^2 Union: " << clock() - startTime << "\n";

	startTime = clock();
	list<int> list4 = nLogNUnion(list1, list2);
	// print(list4);
	cout << "Time for nlogn Union: " << clock() - startTime << "\n";

	startTime = clock();
	list<int> list5 = nSquaredIntersection(list1, list2);
	// print(list5);
	cout << "Time for n^2 Intersection: " << clock() - startTime << "\n";

	startTime = clock();
	list<int> list6 = nLogNIntersection(list1, list2);
	// print(list6);
	cout << "Time for nlogn Intersection: " << clock() - startTime << "\n";

	cout << "\n";

	cout << list1.size() << "\n";
	cout << list2.size() << "\n";
	cout << list3.size() << "\n";
	cout << list4.size() << "\n";
	cout << list5.size() << "\n";
	cout << list6.size() << "\n";
	// cout << list1.size() << "\n";
	// cout << list2.size() << "\n";

}
开发者ID:wclausen,项目名称:ProgrammingPraxis,代码行数:42,代码来源:11_16_12.cpp


注:本文中的std::clock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。