Alvin050789 / kml-samples

Automatically exported from code.google.com/p/kml-samples
0 stars 0 forks source link

Google Earth 5 is an order of magnitude slower at create/update/delete over a network link #244

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Which products are affected?

Google Earth 5.0

What steps will reproduce the problem?

Running GE5 with a network link feeding a large number of
create/update/delete changes

1. Unzip attached file
2. Start running debugGE5.exe
3. Start running Google Earth 5.0
4. Drag-n-drop gecko.kml file to Google Earth
5. See performance results

What is the expected output or behavior? What do you see instead?

Here are the collected timings on my system between GE 4.2 and GE 5.0. I
expected to see GE 5 approximately match GE 4.2 in performance

GE 4.2

Listening on http://*:9142/
Drop gecko.kml onto GE 5 to initiate test
Sending initial.kml
Sending update0.kml
Time: 109.375 Tot: 109 Avg: 109
Sending update1.kml
Time: 109.375 Tot: 218 Avg: 109
Sending update2.kml
Time: 109.375 Tot: 327 Avg: 109
Sending update3.kml
Time: 921.875 Tot: 1248 Avg: 312
Sending update4.kml
Time: 93.75 Tot: 1341 Avg: 268

GE 5.0

Listening on http://*:9142/
Drop gecko.kml onto GE 5 to initiate test
Sending initial.kml
Sending initial.kml
Sending update0.kml
Time: 125 Tot: 125 Avg: 125
Sending update1.kml
Time: 171.875 Tot: 296 Avg: 148
Sending update2.kml
Time: 359.375 Tot: 655 Avg: 218
Sending update3.kml
Time: 9750 Tot: 10405 Avg: 2601
Sending update4.kml
Time: 359.375 Tot: 10764 Avg: 2152

What application versions (if any) are you using?

Google Earth Pro 5.0.11337.1968 (beta).

Which operating systems and browsers are affected?

Running on Windows XP Service Pack 3

Please provide any additional information (code snippets/links) below.

Code below used to serve and profile the performance

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.IO;
using System.Net;
using System.Threading;

namespace debugGE5
{
    class Program
    {
        static private HttpListener listener = null;
        static private Thread serverThread = null;
        static private int updateCount = 0;
        static private DateTime lastTime;
        static private int totTime = 0;
        static private bool firstUpdate = true;
        static private bool done = false;

        static void Main(string[] args)
        {
            if (!HttpListener.IsSupported)
            {
                return;
            }

            listener = new HttpListener();

            listener.Prefixes.Add("http://*:9142/");

            listener.Start();

            if (serverThread == null)
            {
                serverThread = new Thread(listen);
                serverThread.Name = "GEServer";
                //Makes it so the application does not wait for this thread
to finish before it shuts down
                serverThread.IsBackground = true;
                serverThread.Start();
            }

            Console.WriteLine("Listening on http://*:9142/");

            Console.WriteLine("Drop gecko.kml onto GE 5 to initiate test");

            while (serverThread != null && serverThread.IsAlive &&
listener.IsListening)
            {
                System.Threading.Thread.Sleep(1000);
            }

        }

        static public void listen()
        {
            for (; ; )
            {
                // Note: The GetContext method blocks while waiting for a
request. 
                try
                {
                    HttpListenerContext ctx = listener.GetContext();
                    ProcessRequest(ctx);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }

        static private void ProcessRequest(HttpListenerContext context)
        {
            try
            {
                string msg = context.Request.HttpMethod + " " +
context.Request.Url;
                string hostName = context.Request.Url.Host;
                //Console.WriteLine("Receive request " + msg);

                byte[] b;

                string url = msg.Replace("GET ", "");

                if (msg.Contains("initial"))
                {
                    StreamReader s = File.OpenText("initial.kml");

                    Console.WriteLine("Sending initial.kml");

                    b = Encoding.UTF8.GetBytes(s.ReadToEnd());

                    s.Close();

                    updateCount = 0;

                    firstUpdate = true;

                    done = false;

                    totTime = 0;
                }
                else // Anything else is considered an update
                {
                    StreamReader s;

                    if (firstUpdate)
                    {
                        firstUpdate = false;
                    }
                    else if(!done)
                    {
                        TimeSpan diff = DateTime.Now.Subtract(lastTime);

                        totTime += (int)diff.TotalMilliseconds;

                        Console.WriteLine("Time: " + diff.TotalMilliseconds
+ " Tot: " + totTime + " Avg: " + totTime / updateCount);
                    }

                    try
                    {
                        s = File.OpenText("update" + updateCount + ".kml");
                        Console.WriteLine("Sending update" + updateCount +
".kml");
                    }
                    catch (Exception exs)
                    {
                        s = File.OpenText("updateEmpty.kml");
                        done = true;
                        //Console.WriteLine("Sending updateEmpty.kml");
                    }

                    b = Encoding.UTF8.GetBytes(s.ReadToEnd());

                    s.Close();

                    updateCount++;
                }

                context.Response.ContentLength64 = b.Length;
                context.Response.OutputStream.Write(b, 0, b.Length);
                context.Response.OutputStream.Close();
                lastTime = DateTime.Now;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error processing request: " + ex.Message);
            }
        }
    }
}

Original issue reported on code.google.com by oddt...@gmail.com on 16 Feb 2009 at 1:03

Attachments:

GoogleCodeExporter commented 8 years ago
I doubt anyone reads this.

Well, performance has definitely improved in relation to GE 4.2 for the included
benchmark. The official 5.1 release now runs only about 1.5x slower than 4.2 
for this
performance test, as compared to 10x I saw with 5.0. Congratulations!

Original comment by oddt...@gmail.com on 19 Nov 2009 at 1:08