#how can I measure time taken in (ms).

1 messages ยท Page 1 of 1 (latest)

echo sinewBOT
#

โŒ› This post has been reserved for your question.

Hey @outer quarry! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

outer quarry
#

in java

#

@honest cargo

grizzled niche
#

What is this post

#

Strange ๐Ÿ˜•

outer quarry
outer quarry
grizzled niche
#

What's that gotta do with the anime character

outer quarry
#

I dont know where to add

outer quarry
#

@grizzled niche ?

grizzled niche
#

On phone

outer quarry
grizzled niche
#

No, I'll be on pc next on 23 March

outer quarry
#

I need to measure the time taken in (ms) all of the 5 sort

#

oh sad

#

no one can help me

grizzled niche
#

Your question is abstract

#

And code is in a file... phone doesn't preview files

outer quarry
delicate vault
#

./run java

var startTime = System.currentTimeMillis();
try {
Thread.sleep(1000L);
} catch (Exception e) {}
var endTime = System.currentTimeMillis();
var elapsed = endTime - startTime;
System.out.println("wow that took " + elapsed + " ms!");
frigid wagonBOT
#

Here is your java(15.0.2) output @delicate vault

wow that took 1000 ms!
grizzled niche
#

0

delicate vault
#

...

grizzled niche
#

Try to understand it

delicate vault
#

starttime goes before long thing happening

#

endtime goes after long thing happening

outer quarry
#

all of the sort ?

delicate vault
#

printing how long it took goes after endtime

#

i don'tk now whaty our requirement is but i hope this gives you a guide as to how to time how long something took in java

outer quarry
#

I dont know where will I put that

delicate vault
outer quarry
#

I dont know this thats why

#

As u can see I have 5 sort

grizzled niche
#

Not copy it

outer quarry
#

@delicate vault

delicate vault
#

so before each sort make a start time

#

at the end of each sort make an end time and print end minus start

outer quarry
#

But i dont know the start and end of the sort

#

Im lost anymore

delicate vault
#

what's this then:

        int numbers [] = {80, 72, 3, 83, 2, 11, 96, 13, 41, 49, 99, 97, 56, 31, 12, 64, 37, 42, 2, 11, 9, 96, 4, 91, 53, 82, 8, 8, 8, 99, 17, 34, 74, 1, 62, 4, 18, 41, 79, 92, 9, 47, 84, 45, 13, 12, 12, 81, 75, 86, 76, 26, 30, 3, 88, 77, 17, 36, 98, 93, 95, 22, 86, 27, 42, 0, 37, 26, 22, 56, 86, 99, 16, 63, 59, 65, 73, 43, 39, 25, 46, 1, 56, 65, 16, 55, 96, 21, 3, 58, 85, 88, 3, 4, 44, 84, 32, 22, 83, 54};
        System.out.println("Original Array: " + Arrays.toString(numbers));
        insertionSort(numbers);
        selectionSort(numbers);
        mergeSort(numbers);
        quickSort(numbers);
        heapSort(numbers);
    }
outer quarry
#

numbers 1 - 100

#

program that sorts the assigned 100 numbers

#

@delicate vault hello >?

delicate vault
#

hi

#

insertionSort(numbers);
selectionSort(numbers);
mergeSort(numbers);
quickSort(numbers);
heapSort(numbers);

this is a list of all the operations

#

if i were to put a starttime before insertionsort and an endtime after insertionsort how would i do that

delicate vault
#

what would that look like

#

make that change and paste here

outer quarry
#

ok

outer quarry
delicate vault
#

sorry but i think i've given an extensive enough example above and will unfollow this thread

grizzled niche
#

James please don't expect spoonfeeding

outer quarry
#

ok wait

#

making hard time with this sorry

#

can we remove the insertion sort first and insertion ?

#

Just leave it for now

#

The other 3 first sir @delicate vault

outer quarry
outer quarry
#

@delicate vault ?

static plinth
#

System.currentTimeMillis(); is used to get the current time of your computer in ms

#

Include it in the places in the code where you need to keep track of the time