Skip to content

Instantly share code, notes, and snippets.

@emirozturk
Created April 5, 2018 08:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emirozturk/bf8522ffa86bd3c7344a3335dc4658f4 to your computer and use it in GitHub Desktop.
Save emirozturk/bf8522ffa86bd3c7344a3335dc4658f4 to your computer and use it in GitHub Desktop.
NYP 5. Hafta
#include <iostream>
#include <chrono>
using namespace std;
void fonk1(string deger) {
}
void fonk2(string &deger) {
}
int main()
{
chrono::steady_clock::time_point begin;
chrono::steady_clock::time_point end;
for (int miktar = 0; miktar < 10000000; miktar += 1000000)
{
string x = "";
for (int i = 0; i < miktar; i++)
x.append("a");
cout << "uzunluk:" << x.length() << endl;
begin = std::chrono::steady_clock::now();
fonk1(x);
end = std::chrono::steady_clock::now();
long long deger = chrono::duration_cast<chrono::nanoseconds> (end - begin).count();
begin = std::chrono::steady_clock::now();
fonk2(x);
end = std::chrono::steady_clock::now();
long long ref = chrono::duration_cast<chrono::nanoseconds> (end - begin).count();
if (ref == 0)ref = 1;
cout << "Miktar:" << miktar << " Fark:" << deger / ref << " kat" << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment