Jump to content

Recommended Posts

Posted (edited)

Hi, i want some expert to answer me in this question. 

Which is faster:

1.  player.getObject().onDie(); 

2. Interface.invoke("onDie", player);       <-- Example syntax sucks afc.. just to make u understand

I think reflection is no that fast but does it affect performance if for example we do 5 times reflection upon doAttack ? This mean every a player hit it  does 5 invokes. 

 

PS. i did a berchmark in my code: 

It takes 46682 nanoseconds to invoke 5 methods. This mean  0.046682 milliseconds 

Edited by Ο Χάρος
Posted (edited)

Added to the fact it's uglier to read, it's also slower (but not noticeable) to invoke rather than calling it.

If you got no specific use to use invoke, dump it.

Edited by Tryskell
Posted
20 minutes ago, Tryskell said:

Added to the fact it's uglier to read, it's also slower (but not noticeable) to invoke rather than calling it.

If you got no specific use to use invoke, dump it.

It's lot of classes, lots of work and im thinking if it worh the work for just few nanoseconds.. it's really 0.006 max 0.1 millisecond difference to do 4 classes

Posted (edited)
41 minutes ago, SweeTs said:

Access shitcoding since ever, so.. :D

Oh cum on :3 how many account you have O.o

i got chat banned :(  Also shitcoding? i'm sure u remember codes i wrote year ago e.t.c

come on skype and try me bitch i dare u ;( CUM ONNNNNNNNNNNNN

Edited by Ο Χάρος
  • 2 weeks later...
Posted

I really doubt you will have any problems. There is possibility that after a lot of usages, JVM will optimize your code so invoke will run a faster but never as fast as direct call. You might want to debug invoke method to see how many actions are done, you wont be able to monitor native method call though. In Java 8 with Functional Interfaces most likely you dont really need to use reflection, so giving us what you really want to do and we might give you better solution.

Next thing is that you need to make a lot of catches & in future while you or someone else changes name or parameters of doDie method, you will find out about this code when your server crashes.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...