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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock