Using New Profiling API to Analyze Performance of AIMS 2013

简介:


By Daniel Du

前面介绍了AIMS  2013中的性能分析报告工具,同时AIMS 2013也提供了对于的API,这篇文章就讲一下如何使用Profiling API,基本上是代码,不翻译了,如果哪里没看懂的话,评论里提一下。

In previous post, I introduce how to understand the result of performance report. In this post, I will introduce how to use the new profiling API, which makes it possible to create you own performance report.

In AIMS 2013 API, a new service is added, which is MgProfilingService, it is used to profile existing MapGuide APIs.

Here are two methods of MgProfilingService:

virtual MgByteReader *     ProfileRenderDynamicOverlay ( 
          MgMap *map, 
          MgSelection *selection,  
          MgRenderingOptions *options)=0

Profile the process of rendering all dynamic layers in the specified MgMap to a dynamic overlay image with a transparent background.

virtual MgByteReader *     ProfileRenderMap ( 
         MgMap *map, 
         MgSelection *selection, 
         MgCoordinate *center, 
         double scale, 
         INT32 width, INT32 height, 
         MgColor *backgroundColor, 
         CREFSTRING format, 
         bool bKeepSelection)=0

Profile the process of rendering a MgMap to the requested image format with specified center point and scale.

Now let's look at how to use these APIs to get detailed performance report information. AIMS API can be used in Java, PHP or .NET, I would like to use .NET here. Firstly create a AIMS custom WebApplication, and create a custom command to invoke an URL, which is an ASP.NET web page. Here is the source code of web page:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using OSGeo.MapGuide;

 

namespace HelloAIMS2013

{

  publicpartialclassProfilingAPI : System.Web.UI.Page

  {

    protectedvoid Page_Load(object sender, EventArgs e)

    {

      UtilityClass util = newUtilityClass();

      util.InitializeWebTier(HttpContext.Current.Request);

 

      String sessionId = Request["SESSION"].ToString();

 

      util.ConnectToServer(sessionId);

      MgSiteConnection siteConn = util.GetSiteConnection();

 

      MgResourceService resourceService = siteConn

        .CreateService(MgServiceType.ResourceService)

        asMgResourceService;

 

      //Create MgProfilingService instance

 

      MgProfilingService profilingService = siteConn

        .CreateService(MgServiceType.ProfilingService)

        asMgProfilingService;

 

      //open current map

 

      MgMap map = newMgMap();

      if (Request["mapname"] != null)

      {

        string mapName = Request["mapname"].ToString();

        map.Open(resourceService, mapName);

 

        //remove base layer, profiling API doesn't apply to base layers

 

        for (int i = 0; i < map.GetLayers().Count; i++)

        {

          MgLayerBase lyr = map.GetLayers().GetItem(i);

          if (lyr.LayerType == MgLayerType.BaseMap)

          {

            map.GetLayers().Remove(lyr);

          }

        }

        map.Save(resourceService);

 

        #region sample 1, dome of ProfileRenderDynamicOverlay()

 

        string format = "PNG";

 

        // enum    { RenderSelection = 1, RenderLayers = 2, KeepSelection = 4 }

        // Rendering behavior values.

        //RenderSelection - Renders the selected feature(s).

        //RenderLayers - Renders the features on the map.

        //KeepSelection - Renders the selected feature(s) even if they are outside the current scale.

 

        int behavior = 2;

        MgColor selectionColor = newMgColor(System.Drawing.Color.Blue);

        MgRenderingOptions renderingOptions = newMgRenderingOptions(format,behavior, selectionColor);

 

        MgByteReader byteReader = profilingService.ProfileRenderDynamicOverlay(

          map,

          null//MgSelection, do not have selection here

          renderingOptions);

 

        //Store in a file

        MgByteSink byteSink = newMgByteSink(byteReader);

        byteSink.ToFile(@"c:\delete\profilingResult.txt");

 

        Response.Write(@"write result to c:\delete\profilingResult.txt <br/>");

 

        #endregion

 

        #region Sample 2, demo of ProfileRenderMap

 

        MgCoordinate center = map.ViewCenter.Coordinate;

        double scale = map.ViewScale;

        int width = Convert.ToInt32(map.GetDisplayWidth());

        int height = Convert.ToInt32(map.GetDisplayHeight());

        MgColor backgroundColor = newMgColor(map.GetBackgroundColor());

        string format2 = "PNG";

        bool bKeepSelection = true;

 

        MgByteReader byteReader2 = profilingService.ProfileRenderMap(

          map,

          null,//MgSelection

          center,

          scale,

          width,

          height,

          backgroundColor,

          format2,

          bKeepSelection);

 

        //Store in a file

        MgByteSink byteSink2 = newMgByteSink(byteReader2);

        byteSink2.ToFile(@"c:\delete\profilingResult2.txt");

 

        Response.Write(@"write result to c:\delete\profilingResult2.txt<br/>");

 

        #endregion

 

 

      }

    }

  }

}

The code is selfexplanatory, it does performance report based on current map extent and current scale, and write the performance report result into a text file in XML format. These XML files include detailed information of performance. For example, you can find the total rendering time and time cost of each layer:

image

With these detailed information, you can implement your own performance report yourself.

If you want to know more about the performance report of AIMS Site Administrator, it is in PHP, all source code is released with the product, you can find then at <Infrastructure Web Server Extension 2013>\www\mapadmin.

OK, with that I draw an end to this post, do you think the profiling API is useful? You are welcome to leave us a comment below about your thought. We are always eager to hear from you.

作者: 峻祁连
邮箱:junqilian@163.com 
出处: http://junqilian.cnblogs.com 
转载请保留此信息。




本文转自峻祁连. Moving to Cloud/Mobile博客园博客,原文链接:http://www.cnblogs.com/junqilian/archive/2012/07/16/2590654.html ,如需转载请自行联系原作者
相关文章
|
6月前
|
存储 缓存 数据库连接
每日一博 - How To Improve API Performance
每日一博 - How To Improve API Performance
21 0
|
存储 Cloud Native NoSQL
【Paper Reading】Cloud-Native Transactions and Analytics in SingleStore
HTAP & 云原生是如今数据库技术演进的两大热点方向。HTAP 代表既有传统的 HANA Delta RowStore+Main ColumnStore,Oracle In-MemoryColumnStore 等方案,也有像 TiDB,Snowflake Unistore这样新的技术架构;云原生代表则是以 S3 为低成本主存的 Snowflake,Redshift RA3,提供灵活弹性和Serverless 能力。SingleStore 则是首次把两者结合起来,基于计算存储分离的云原生架构,用一份存储提供低成本高性能的 HTAP 能力。
【Paper Reading】Cloud-Native Transactions and Analytics in SingleStore
|
10月前
Query Performance Optimization at Alibaba Cloud Log Analytics Service
PrestoCon Day 2023,链接:https://prestoconday2023.sched.com/event/1Mjdc?iframe=no首页自我介绍,分享题目概要各个性能优化项能够优化的资源类别limit快速短路有什么优点?有啥特征?进一步的优化空间?避免不必要块的生成逻辑单元分布式执行,global 阶段的算子哪些字段无需输出?公共子表达式结合FilterNode和Proje
Query Performance Optimization at Alibaba Cloud Log Analytics Service
sbs
|
SQL 存储 监控
One SQL to Rule Them All: An Efficient and Syntactically Idiomatic Approach to Management of Streams and Tables 论文翻译
One SQL to Rule Them All: An Efficient and Syntactically Idiomatic Approach to Management of Streams and Tables[文件: One SQL to Rule Them All- An Efficient and Syntactically Idiomatic Approach to Manag
sbs
160 0
One SQL to Rule Them All: An Efficient and Syntactically Idiomatic Approach to Management of Streams and Tables 论文翻译
|
SQL 存储 算法
《Optimization of Common Table Expressions in MPP Database Systems》论文导读
Optimization of Common Table Expressions in MPP Database Systems
《Optimization of Common Table Expressions in MPP Database Systems》论文导读
|
算法 前端开发 调度
The Cascades Framework for Query Optimization
这篇paper是前一篇Volcano optimizer的后续,其涉及的概念和优化思路是一脉相承的,在阅读本篇之前,最好对Volcano optimizer有足够的了解,详见文章Volcano优化器框架。
414 0
|
SQL 存储 算法
The MemSQL Query Optimizer: A modern optimizer for real-time analytics in a distributed database
今天我们要介绍的MemSQL就采用这样一种新的形态(Oracle也变为了这种方式 ):即在做transformation时,要基于cost确定其是否可应用。 当然,本篇paper不止讲解了CBQT,还包括一些MemSQL优化器其他方面的介绍,包括一个有意思的heurstic based bushy join的方案。
344 0
The MemSQL Query Optimizer: A modern optimizer for real-time analytics in a distributed database
|
Web App开发 tengine 安全
Understanding HTTP/2: History, Features, Debugging, and Performance
HTTP/2 is an optimized transfer protocol over the previous version and offers various advantages, such as increased security, simplified development p.
1977 0
|
SQL 固态存储 关系型数据库
Performance Evaluation Methods for Distributed MPP Databases - Best Practice for PostgreSQL
Evaluating the performance of a database usually involves either industry standard testing or modeling testing based on the business model.
2188 0