sc.base.cdn
===========

First some initial setup code:

    >>> from zope.component import getUtility
    >>> import time
    >>> from Products.CMFCore.interfaces import IPropertiesTool
    >>> ptool = getUtility(IPropertiesTool)

Benchmark
---------

Login as portal manager::

    >>> self.loginAsManager()

Define a benchmark function::

    >>> def bench(tool,attr,**kw):
    ...     i=5000
    ...     a=getattr(tool,attr)
    ...     start=time.time()
    ...     while i:
    ...         url = a(**kw)
    ...         i-=1
    ...     delta=time.time()-start
    ...     return delta

Call base version of absolute_url::

    >>> tool = getattr(self.portal, 'portal_javascripts')
    >>> nonPatched = bench(tool,'absolute_url_old')

Call patched version:

    >>> tool = getattr(self.portal, 'portal_javascripts')
    >>> patched = bench(tool,'absolute_url')

Difference::
    
    >>> print nonPatched, patched, patched / nonPatched


Call base version of absolute_url, using relative::

    >>> tool = getattr(self.portal, 'portal_javascripts')
    >>> nonPatched = bench(tool,'absolute_url_old',**{'relative':1})

Call patched version , using relative:

    >>> tool = getattr(self.portal, 'portal_javascripts')
    >>> patched = bench(tool,'absolute_url',**{'relative':1})

Difference::
    
    >>> print nonPatched, patched, patched / nonPatched