C:\aWork\UI\Perf\NbProj\web\AnonymousJsVsNamed.jsp
 1 /*<%--
 2     Document   : AnonymousJsVsNamed.jsp
 3     Created on : 2010-01-28
 4     Author     : Sasha Firsov
 5 
 6     @param      Count
 7     @param      UseVar  if 'Var' use  var XXX=function(){...}, otherwise function XXX(){...}
 8     @param      Global  if not 'Global' wrap into function making all tested functions local
 9     @param      Half    if 'Half' only each second declared function actually called
10 
11 BSD type licence.
12 Copyright (c) 2010, Sasha Firsov, Simulation Works, LLC
13 All rights reserved.
14 
15 Redistribution and use in source and binary forms, with or without modification,
16 are permitted provided that the following conditions are met:
17 
18     * Redistributions of source code must retain the above copyright notice,
19         this list of conditions and the following disclaimer.
20     * Redistributions in binary form must reproduce the above copyright notice,
21         this list of conditions and the following disclaimer in the
22         documentation and/or other materials provided with the distribution.
23     * Neither the name of the Simulation Works, LLC nor the names of its
24         contributors may be used to endorse or promote products derived from
25         this software without specific prior written permission.
26 
27 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
28 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
29 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
30 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
31 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
32 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
33 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
34 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 
38 --%><%@page contentType="text/javascript" pageEncoding="UTF-8" language="java" import="java.lang.*"
39 %><%
40     int MaxCount = 1000;
41     try{ MaxCount = java.lang.Integer.parseInt( request.getParameter("Count"    ) );    }catch( Exception ex ){ out.println("Count defaulted to "+MaxCount ); }
42     boolean UseVar  = "Var"     .equals( request.getParameter("UseVar"  ) );
43     boolean Global  = "Global"  .equals( request.getParameter("Global"  ) );
44     boolean Half    = "Half"    .equals( request.getParameter("Half"    ) );
45 //  out.println("UseVar="+UseVar);
46 //  out.println("Half="+Half);
47     out.println("MaxCount="+MaxCount);
48     String fName="Function"+request.getParameter("BASE")+(UseVar?"Var":"Fun");
49 %>*/
50 beginTime=T();
51 RealCount = 1;
52 <%=Global?"//":""%>function Gbl<%=fName%>(){
53 <%  for( int i=0; i<MaxCount; i++ )
54     {
55         String name=fName+i;
56 %>
57 <%      if(UseVar)
58             {   %>var <%=name%>=function<%  }
59         else
60             {   %>function <%=name%><%      }
61                 %>(){ window.RealCount=<%=i%>; }
62 if( !SkipEachOdd || <%=(i&1)%> )
63     <%=name%>();
64         <%
65     }
66 %>
67 <%=Global?"//":""%>}Gbl<%=fName%>();
68