|
From: john c. <joh...@ya...> - 2001-08-16 04:51:03
|
Was the results of this experiment uninteresting? No
comments? There seemed to be a lot of enthusiasm at
one point but no longer. Hmmm... what are you fellas
up to? I would really like to refine this idea, and
will need your help doing so.
Note: because of the size of the text box window, the
code is not formatted correctly. But it is easy to
deduce how it is supposed to look like.
--- john coppola <joh...@ya...> wrote:
> So, this weekend I got a working prototype of the
> skeletons model functioning.
>
> The speed boost for batch processing was roughly 8x
> faster than regular native Jython. Not quite the
> speed boost I was looking for. I was hoping for at
> least 20x performance boost.
>
> Here are the simple data structures used:
>
> class DataRecord:
> def __init__(self):
> self.name = 'test'
> self.wage = 10.0
> self.hours = 40.0
>
> class WorkHistory:
> def __init__(self):
> self.name = 'test'
> self.workhistory = []
>
> def add_record(self,ob):
> self.workhistory.append(ob)
>
> def compute_total(self):
> total = 0.0
> for ob in self.workhistory:
> total = total + ob.wage*ob.hours
> return total
>
> def test():
> from time import time
> wh=WorkHistory()
> # populate wh
> for i in xrange(0,1000):
> wh.add_record(DataRecord())
> start = time()
> wh.compute_total()
> print time()-start
>
> So in native Jython without skeletons this took:
> 0.03 seconds to calculate
>
> Now skeletons where applied in this way using getter
> and setter style methods on native java skeleton
> class.
>
> public class WorkHistorySkeleton extends
> PyJavaSkeleton {
> public PyList workhistory = new PyList();
>
> public void set_workhistory(PyObject ob) {
> workhistory = ob;
> }
>
> public PyList get_workhistory() {
> return workhistory;
> }
>
> public double compute_total() {
> double total = 0.0;
> for (int i;i<workhistory.__len__();i++) {
> PyObject ob =
> workhistory.__getitem__(i);
> DataRecordSkeleton sk =
> (DataRecordSkeleton) ob.__skeleton__()
> total += sk.wage*sk.hours
> }
> return total
> }
> }
>
> public class DataRecordSkeleton extends
> PyJavaSkeleton
> {
> public double wage = 0.0;
> public double hours = 0.0;
>
> public void set_wage(PyObject ob) {
> wage=((PyFloat) ob).getValue();
> }
> public double get_wage() {
> return wage;
> }
>
> public void set_hours(PyObject ob) {
> hours=((PyFloat) ob).getValue();
> }
> public double get_hours() {
> return hours;
> }
> }
>
> So for my test:
> def test():
> from time import time
>
wh=WorkHistory(__skeleton__='WorkHistorySkeleton')
> # populate wh
> for i in xrange(0,1000):
>
>
wh.add_record(DataRecord(__skeleton__='DataRecordSkeleton'))
> start = time()
> wh.compute_total()
> print time()-start
>
> it takes 0.0036 seconds for this code to execute
> with
> skeletons.
>
>
> Perhaps multiple inheritence is the way to go for
> this. But there are still some issues that have to
> be
> addressed. In this code, we can explicitly retrieve
> the skeleton object and use it directly in native
> java
> because it is native java. To utilize the speed of
> native java from a hybrid class inheriting from both
> a
> java class and a python class a technique must be
> developed to rapidly retrieve only that part of the
> object's construction. This way we can work with
> the
> native java component of the object without the need
> for ((PyFloat)__findattr__('<name>')).getValue() or
> __findattr__('<name>').__str__() or whatever. This
> layer is removed thus making things faster.
>
> Also ob.__skeleton__() is a one step process and the
> skeleton backbone is retrieved. The hypothetical
> coercion mechanism developed to retrieve only the
> java
> part of an object would have to be at least as fast
> as
> the ob.__skeleton__() method.
>
> For people following this thread, please let me know
> what you think. If you'd like to see the actual
> code
> I've whipped up let me know cause the code here I
> wrote out of my head (dont have my laptop with me).
>
> So, let me know what you think.
>
> peace,
> John Coppola
>
>
>
>
>
>
>
>
>
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Send instant messages & get email alerts with Yahoo!
> Messenger.
> http://im.yahoo.com/
>
> _______________________________________________
> Jython-dev mailing list
> Jyt...@li...
>
http://lists.sourceforge.net/lists/listinfo/jython-dev
__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/
|