Example #1
0
        static void FastTemplateTest(Dictionary <Tree, Dictionary <Tree, Dictionary <Tree, List <Tree> > > > treeList)
        {
            TemplateEngine.Init(new HashSet <string>(), "/static/fastTemplate");
            List <long> timeList     = new List <long>();
            long        milliseconds = 0;
            Stopwatch   watch        = new Stopwatch();

            for (int i = 0; i < 10000; i++)
            {
                watch.Reset();
                watch.Start();
                TemplateEngine.Compile("/static/fastTemplate/list.html", new Dictionary <string, dynamic> {
                    { "list", treeList }
                });
                watch.Stop();
                milliseconds = watch.ElapsedMilliseconds;
                if (milliseconds == 0)
                {
                    continue;
                }
                timeList.Add(milliseconds);
            }

            Console.WriteLine(string.Format("FastTemplateTest min:{0},max:{1} totalCount:10000 milliseconds > 0 count:{2}", timeList.Min(), timeList.Max(), timeList.Count));
        }
        public moregadgets()
        {
            if (this.userid < 1)
            {
                HttpContext.Current.Response.Redirect(forumurlnopage + "/login.aspx?reurl=space");
                return;
            }
            GetOnlineUserInfo();

#if NET1
            TabInfoCollection tc = Spaces.GetTabInfoCollectionByUserID(this.userid);
#else
            Discuz.Common.Generic.List <TabInfo> tc = Spaces.GetTabInfoCollectionByUserID(this.userid);
#endif

            currentUserSpaceConfig = Spaces.GetSpaceConfigByUserId(this.userid);
            int            defaultTabId = Spaces.GetDefaultTabId(currentUserSpaceConfig, tc);
            string         html         = StaticFileProvider.GetContent(templatePath + "moregadgets.htm");
            TemplateEngine te           = new TemplateEngine();
            te.Init(html, templatePath);
            te.Put("tabid", defaultTabId);
            te.Put("forumpath", BaseConfigs.GetForumPath);
            te.Put("config", currentUserSpaceConfig);
            te.Put("username", this.olusername);
            te.Put("userid", this.oluserid);
            te.Put("userkey", oluserkey);
            te.Put("forumurlnopage", forumurlnopage);
            double processtime = new TimeSpan(DateTime.Now.Ticks).Subtract(begints).Duration().TotalSeconds;
            te.Put("processtime", processtime);
            html = te.MergeTemplate();
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(html);
            HttpContext.Current.Response.End();
        }
Example #3
0
 static void Main(string[] args)
 {
     TemplateEngine.IsDebug = false;
     TemplateEngine.Init(new HashSet <string> {
         "Common.dll"
     });
     //BaseTest();
     //IfTest();
     //ElseIfTest();
     //EachTest();
     //IncludeTest();
     //LayoutTest();
     UsingTest();
 }