Ignore:
Timestamp:
Nov 16, 2018, 10:38:46 PM (6 years ago)
Author:
alloc
Message:

*Latest optimizations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • binary-improvements/MapRendering/Web/API/WebAPI.cs

    r326 r332  
    22using System.Text;
    33using AllocsFixes.JSON;
     4using UnityEngine.Profiling;
    45
    56namespace AllocsFixes.NetConnections.Servers.Web.API {
     
    1112                }
    1213
     14#if ENABLE_PROFILER
     15                private static readonly CustomSampler jsonSerializeSampler = CustomSampler.Create ("JSON_Serialize");
     16                private static readonly CustomSampler netWriteSampler = CustomSampler.Create ("JSON_Write");
     17#endif
     18
    1319                public static void WriteJSON (HttpListenerResponse resp, JSONNode root) {
     20#if ENABLE_PROFILER
     21                        jsonSerializeSampler.Begin ();
     22#endif
    1423                        StringBuilder sb = new StringBuilder ();
    1524                        root.ToString (sb);
     25#if ENABLE_PROFILER
     26                        jsonSerializeSampler.End ();
     27                        netWriteSampler.Begin ();
     28#endif
    1629                        byte[] buf = Encoding.UTF8.GetBytes (sb.ToString ());
    1730                        resp.ContentLength64 = buf.Length;
     
    1932                        resp.ContentEncoding = Encoding.UTF8;
    2033                        resp.OutputStream.Write (buf, 0, buf.Length);
     34#if ENABLE_PROFILER
     35                        netWriteSampler.End ();
     36#endif
    2137                }
    2238
Note: See TracChangeset for help on using the changeset viewer.