hi guys!
Thus anyone know how to put timer in bubble sort using javascript???

I am trying to make a timer for my sort but I can't make it. I don't know how to connect...

heres my work..

<!-- Begin
var myArray = new Array(102,201,3,517,77,345,68,234,8,9,4,517,6,0)

function bubbleSort(ns,test) {
ts=new Date();
//ns = myArray

alert("Sorted array: \n"+ns)
alert("time to sort =\n"+(ts)+" milliseconds")
// End -->

<body onLoad="bubbleSort(myArray,'<');">


5 Years
Discussion Span
Last Post by MartinRinehart

<vent>Tell your instructor that at least one highly experienced coder thinks he should be fired. Asking students to code a bubble (or other) sort is absurd. Sort algorithms are non-trivial but fully explored. In any modern language you call a 'sort()' method and you will never have to code a sort.</vent>

Now to your question. You time anything by a) finding a nice tester (Google) or b) writing your own. Option b can be trivial. Untested code:

var start = new Date();
do routine_to_be_timed();
alert( new Date() - start );
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.