goete111 / factorie

Automatically exported from code.google.com/p/factorie
0 stars 0 forks source link

ArrayOps uses structural types in wrapper which causes reflection #23

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi, I was using FACTORIE and peeking around the source code and I noticed that 
the ArrayOps wrapper for adding operations on arrays uses an implicit 
conversion to an anonymous (structural) type.

From what I understand, these sorts of types have their methods invoked using 
reflection, so this could cause some slowdown if those wrapper methods are used 
a lot. 

I've attached a tiny patch to change the ArrayOps implicit to use a named 
wrapper trait. "testGradientAscent", which uses these operations a bit, ran on 
my machine in an average of 0.43 - 0.46 seconds before the patch, and .39 - .42 
afterwards. I haven't done enough tests to be really sure, but it looks like a 
modest ~10% speedup in that case.

Apologies if this is not the right way to submit a patch, I'm new to Google 
Code and Mercurial.

Original issue reported on code.google.com by LVilnis@gmail.com on 23 Mar 2012 at 12:01

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks, Luke! Commited and closed.

Original comment by alexandr...@gmail.com on 23 Mar 2012 at 4:18