Access time of instance versus session variable

classic Classic list List threaded Threaded
5 messages Options
SD
Reply | Threaded
Open this post in threaded view
|

Access time of instance versus session variable

SD
Hi,

I have an xml instance on page A which I store it in session before redirecting to page B. On page B, I have to access this session-attribute multiple times. Will it be faster to access this instance directly via session (xxforms:get-session-attribute('xxx')) or is it advisable to store this session-attribute in a new instance on page B and access that instance on page B.

Thanks in advance
--SD

 
Reply | Threaded
Open this post in threaded view
|

Re: Access time of instance versus session variable

Erik Bruchez
Administrator
SD,

I wouldn't expect to see much difference between the two, but the only
way to really know would be to measure the respective performance.

-Erik

On Wed, Sep 7, 2011 at 11:57 AM, SD <[hidden email]> wrote:

> Hi,
>
> I have an xml instance on page A which I store it in session before
> redirecting to page B. On page B, I have to access this session-attribute
> multiple times. Will it be faster to access this instance directly via
> session (xxforms:get-session-attribute('xxx')) or is it advisable to store
> this session-attribute in a new instance on page B and access that instance
> on page B.
>
> Thanks in advance
> --SD
>
>
>
> --
> View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Access-time-of-instance-versus-session-variable-tp3796952p3796952.html
> Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
SD
Reply | Threaded
Open this post in threaded view
|

Re: Access time of instance versus session variable

SD
Erik,

I preformed a little experiment to understand it and these are my results.

Page A,
1. Has a big instance (82 xml nodes in it) like this
<xforms:instance id="exp">
    <root>
        <1/>
        <2/>
        <3/>
        ....
        <82/>
    </root>
</xforms:instance>
2. Created a trigger on Page A and on click stored this instance in session and redirected the app to Page B

Page B
1. On xforms-ready, copied the entire session instance into a local instance
<xforms:instance id="exp2">

2. Created 2 triggers, Trigger Session  and Trigger Instance

3. On click of Trigger Session I start the timer, and do a setvalue of all the 82 nodes into a test instance from the session instance and then stop the timer

4. On click of Trigger Instance I start the timer, and do a setvalue of all the 82 nodes into a test instance from the exp2 instance and then stop the timer

The results are as follows

Average access time for the session instance = 63.37 ms
Average access time for the exp2 instance = 21.25 ms

I clearly see that the exp2 instance is better in performance, but is it really worth having this instance in memory and maintaining it (whenever and wherever exp2 is updated I have to update session instance as well).
Should I use the session instance at the cost of performance? or should I use the exp2 instance at the cost of more storage memory and maintenance?

Thanks
--SD
Reply | Threaded
Open this post in threaded view
|

Re: Re: Access time of instance versus session variable

Erik Bruchez
Administrator
> Average access time for the session instance = 63.37 ms
> Average access time for the exp2 instance = 21.25 ms

Interesting numbers. I wonder why reading/writing to the session map
would be that much slower!

> I clearly see that the exp2 instance is better in performance, but is it
> really worth having this instance in memory and maintaining it (whenever and
> wherever exp2 is updated I have to update session instance as well).
> Should I use the session instance at the *cost of performance*? or should I
> use the exp2 instance at the *cost of more storage memory* and
> *maintenance*?

I would probably choose to use the session to simplify the code, but
it's just me!

-Erik


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
SD
Reply | Threaded
Open this post in threaded view
|

Re: Re: Access time of instance versus session variable

SD
Thanks Erik, It helps a lot :D

--SD