How to get loading time?

61 views
Skip to first unread message

Christian LeMoussel

unread,
Apr 28, 2015, 1:30:57 AM4/28/15
to cefs...@googlegroups.com
Does exist some method/propery to measure the loading time of HTML page?
If the loading time is too long, is it possible to stop the loading of the HTML page?

Best regards,

Christian.

Alex Maitland

unread,
Apr 28, 2015, 4:07:39 AM4/28/15
to cefs...@googlegroups.com
Not that I've seen. You can probably just hook one of the loading event handlers, using a timer and call Stop() if the timer executes.

Christian LeMoussel

unread,
Apr 28, 2015, 8:40:05 AM4/28/15
to cefs...@googlegroups.com
Alex,

or another way is to use task object for StartNew method and then user Wait method to determine timeout.
eg :

using System;
using System.Threading;
using System.Threading.Tasks;

namespace TaskTimeOut
{  
   
class Program
   
{
       
static void Main(string[] args)
       
{
           
TimeSpan timeout = TimeSpan.FromMilliseconds(5000);

           
Task timeOutTask = Task.Factory.StartNew(() =>
           
{
               
try
               
{
                   
// Simulate the long running computation
                   
Thread.Sleep(10000);
               
}
               
catch (Exception ex) { Console.WriteLine(ex.Message); }
           
}, TaskCreationOptions.LongRunning);
           
//  With TaskCreationOptions.LongRunning option, it will have a dedicated Thread for it's execution and does not interfere with normal behavior of ThreadPool by occupying a thread from there for too long.
           
           
if (!timeOutTask.Wait(timeout))
           
{
               
// throw exception or something else if timeout
               
Console.WriteLine("Time Out");
               
Console.ReadKey();
           
}

       
}
   
}
}



Best regards,

Christian.

Bill Tutt

unread,
Apr 28, 2015, 7:40:35 PM4/28/15
to cefs...@googlegroups.com
Err, shouldn't you be able to get the info from Dev Tools just like in Chrome?
Particularly the Network/Timeline/Profiler tabs?

Bill

Christian LeMoussel

unread,
May 12, 2015, 3:41:57 AM5/12/15
to cefs...@googlegroups.com
Well, well,

But I use OffScreen browser.
Is it possible to get informations from Dev Tools with C# code ?

Alex Maitland

unread,
May 12, 2015, 4:31:11 AM5/12/15
to cefs...@googlegroups.com
You have to use `ChromeDriver` to access such things. Unsure exactly how much network info is exposed.

https://bitbucket.org/chromiumembedded/cef/wiki/UsingChromeDriver.md
http://stackoverflow.com/a/22502405/4583726

Let us know what you find out.

Christian LeMoussel

unread,
May 12, 2015, 8:49:17 AM5/12/15
to cefs...@googlegroups.com
Alex,

Without use of another technology or ChromeDriver, and as described in this presentation Performance Metrics in a Day with Selenium for gathering metrics 2 methods :

Method 1: Own Timings

Date start = new Date();
// Some stuff ....,
// Get HTML Page
Date end = new Date();
But I think It's a
naive attempt to measure the time it takes to fully load a page.

Method 2 : Web Timings
Use
W3C API navigation timing
In this case if I understand the specifications in chapter 5.1 Processing Model and in slide 9 of the presentation
Page loading time
would equal to
: loadEventEnd - navigationStart

It's this method that I will try to integrate with JavaScript  in CefSharp.


Christian.





Reply all
Reply to author
Forward
0 new messages