[]

Kodun Çalışma süresini hesaplama
Arkadaşlar benim şimdi sıralama algoritmalarını tek tek çalıştırıp çalışma sürelerini yazdırmam gerekiyor. (C dilinde) ama nasıl yapacağımı bilemiyorum, yani bir kodun çalışma süresini nasıl yazdırabilirim yardımcı olabilir misiniz?

kodun başında bi değişkene o anki zamanın saniye ya da salise cinsinden değerini yazdır.
kodun bitimine de yine aynı şekilde o anki zamanı ikinci bi değişkene yazdır
sonra ikinci değişkenden ilk değişkeni çıkar.
şöyle bişi yani
zaman1: şuankizaman
kodmodbişiler
kodlar modlar
zaman2: şuankizaman
gecensure: zaman2-zaman1
kusura bakma c bilmediğim için kod ile örnek veremiyorum ama ben böyle bi mantıkla yapmıştım başka bi dilde.
kodun bitimine de yine aynı şekilde o anki zamanı ikinci bi değişkene yazdır
sonra ikinci değişkenden ilk değişkeni çıkar.
şöyle bişi yani
zaman1: şuankizaman
kodmodbişiler
kodlar modlar
zaman2: şuankizaman
gecensure: zaman2-zaman1
kusura bakma c bilmediğim için kod ile örnek veremiyorum ama ben böyle bi mantıkla yapmıştım başka bi dilde.
- birisi.
(08.03.15 01:30:05 ~ 01:31:24)

Javascriptte böyle oluyor:
var SpeedTest = function(testImplement,testParams,repetitions){
this.testImplement = testImplement;
this.testParams = testParams;
this.repetitions = repetitions || 10000;
this.average = 0;
};
SpeedTest.prototype = {
startTest: function(){
if( this.testImplement( this.testParams ) === false ){
alert("Yo, man, that test failed with those parameters.");
return;
}
var beginTime, endTime, sumTimes = 0;
for (var i = 0, x = this.repetitions; i < x; i++){
beginTime = +new Date();
this.testImplement( this.testParams );
endTime = +new Date();
sumTimes += endTime - beginTime;
}
this.average = sumTimes / this.repetitions;
return console.log("Average execution across " + this.repetitions + ": " + this.average);
}
};
var SpeedTest = function(testImplement,testParams,repetitions){
this.testImplement = testImplement;
this.testParams = testParams;
this.repetitions = repetitions || 10000;
this.average = 0;
};
SpeedTest.prototype = {
startTest: function(){
if( this.testImplement( this.testParams ) === false ){
alert("Yo, man, that test failed with those parameters.");
return;
}
var beginTime, endTime, sumTimes = 0;
for (var i = 0, x = this.repetitions; i < x; i++){
beginTime = +new Date();
this.testImplement( this.testParams );
endTime = +new Date();
sumTimes += endTime - beginTime;
}
this.average = sumTimes / this.repetitions;
return console.log("Average execution across " + this.repetitions + ": " + this.average);
}
};
- exordinary
(08.03.15 06:28:29)
1