Time |
S |
Nick |
Message |
01:23 |
|
|
aditsu joined ##friendlyjava |
02:44 |
|
|
aditsu joined ##friendlyjava |
02:45 |
|
|
aditsu_ joined ##friendlyjava |
02:48 |
|
|
Frank89RM_ joined ##friendlyjava |
06:38 |
|
|
noreason joined ##friendlyjava |
07:40 |
|
|
usandfriends joined ##friendlyjava |
08:58 |
|
mr_lou |
Trivialt topic. |
08:58 |
|
mr_lou |
Which is better/faster? |
08:58 |
|
mr_lou |
string.startsWith(), or |
08:58 |
|
mr_lou |
string.substring() ? |
09:11 |
|
noreason |
mr_lou it depends on condition isnt it ? |
09:12 |
|
noreason |
startsWith is completely different case with subString() dont you think so ? |
09:18 |
|
noreason |
jeez all the guyz are here uses framework always :P awww |
09:32 |
|
noreason |
i like regex than loop |
09:35 |
|
mr_lou |
Fine |
09:35 |
|
mr_lou |
string.startsWith("Hi") vs string.substring(0,1).equals("Hi") |
09:35 |
|
mr_lou |
Better? |
09:36 |
|
mr_lou |
Ups |
09:36 |
|
mr_lou |
substring(0,2) |
09:37 |
|
* mr_lou |
reminds noreason this is #friendlyjava. Attitudes belong elsewhere. |
09:38 |
|
mr_lou |
I suppose I could just run my own test, as I usually do. |
09:56 |
|
mr_lou |
Wow.... substring().equals is faster. Didn't expect that. |
09:57 |
|
mr_lou |
236 seconds to ask a million times or so. 250 seconds to ask for startsWith() |
10:03 |
|
|
noreason joined ##friendlyjava |
11:05 |
|
pdurbin |
technically it's ##friendlyjava :) |
13:48 |
|
|
Patch_ joined ##friendlyjava |
14:20 |
|
|
Patch joined ##friendlyjava |
16:17 |
|
mr_lou |
Oh right. |
16:33 |
|
pdurbin |
:) |
17:39 |
|
aditsu |
mr_lou: a whopping 5% faster? :) |
17:43 |
|
mr_lou |
hehe |
17:43 |
|
mr_lou |
I'm still surprised though. I expected startsWith to be faster. |
17:43 |
|
mr_lou |
Remarkably faster. |
17:44 |
|
mr_lou |
And then instead, it's slower. |
17:44 |
|
|
stuntmania joined ##friendlyjava |
17:57 |
|
mr_lou |
Hm, interesting. |
17:57 |
|
mr_lou |
I just ran the test again, but this time only asking for 1 character. The previous test was for 2 characters. |
17:57 |
|
mr_lou |
Now startsWith is faster. |
17:57 |
|
mr_lou |
Takes 207 seconds, while substring().equals() takes 223 seconds. |
17:58 |
|
aditsu |
try 20 chars or something |
18:00 |
|
mr_lou |
Alright |
18:07 |
|
mr_lou |
With 20 characters, substring().equals() takes 237 seconds. |
18:12 |
|
mr_lou |
I feel I'm waiting forever for startsWith() to complete. |
18:14 |
|
mr_lou |
startsWith() takes 569 seconds. |
18:14 |
|
aditsu |
:O |
18:14 |
|
mr_lou |
yea... |
18:19 |
|
mr_lou |
Testing again with 1 char, adding charAt(0) as well. |
18:19 |
|
mr_lou |
But keeping string length from before. |
18:38 |
|
mr_lou |
Wow |
18:38 |
|
mr_lou |
substring(0,1).equals() took 205 seconds. |
18:38 |
|
mr_lou |
startsWith() took 186 seconds |
18:38 |
|
mr_lou |
charAt(0) took 37 seconds. |
18:49 |
|
aditsu |
of course charAt is fast |
18:54 |
|
* mr_lou |
wonders of obfuscators are clever enough to convert startsWith() to charAt(0) when only one char is used. |
18:54 |
|
mr_lou |
*if |
18:58 |
|
aditsu |
that would be an optimizer, not obfuscator :) |
18:58 |
|
aditsu |
anyway, you'd also need a length check |
19:01 |
|
mr_lou |
Well, aren't optimizers usually built into obfuscators? |
19:04 |
|
aditsu |
don't know enough obfuscators to answer that :p |
20:00 |
|
|
noreason joined ##friendlyjava |
20:00 |
|
noreason |
mr_lou |
20:21 |
|
mr_lou |
What? |
20:22 |
|
noreason |
help plz |
20:22 |
|
noreason |
mr_lou |
20:23 |
|
noreason |
want to find difference between dates |
20:24 |
|
noreason |
aditsu |
20:25 |
|
mr_lou |
Really sounds like something you can find easily with google |
20:28 |
|
noreason |
tried couple of those seriously i'm getting confused |
20:32 |
|
mr_lou |
http://stackoverflow.com/questions/1555262/calculating-the-difference-between-two-java-date-instances |
20:37 |
|
noreason |
they talk about joda library |
20:37 |
|
noreason |
i dont use more library |
20:39 |
|
aditsu |
noreason: you can convert them to milliseconds and subtract |
20:39 |
|
noreason |
i used Calendar |
20:39 |
|
noreason |
than dateformat err didnt work |
20:43 |
|
noreason |
want to shift java 8 FASTTTTTTTTTTTTTTTTTTTTTTTT |
20:48 |
|
mr_lou |
noreason, So you don't have two Date objects? You have two Calendar objects that you wish to substract to know how long time is between them? |
20:49 |
|
noreason |
k its my bad , made a mistake |
20:49 |
|
noreason |
aditsu its all my mistake |
20:49 |
|
mr_lou |
Calendar objects has a getTimeInMillis() function you can call. |
20:49 |
|
noreason |
mr_lou fine! |
20:50 |
|
mr_lou |
long timeBetweenDates = calendar1.getTimeInMillis() - calender2.getTimeInMillis(); |
20:52 |
|
noreason |
mr_lou i got it working |
20:52 |
|
noreason |
<noreason> k its my bad , made a mistake |
20:52 |
|
noreason |
<noreason> aditsu its all my mistake |
20:53 |
|
noreason |
aditsu why i make alot of mistakes am i learning ? :* |