     }
   }
   
+  func timestamp() -> Double {
+    let now = DispatchTime.now()
+    let nanoTime = now.uptimeNanoseconds - startTime.uptimeNanoseconds
+    let elapsed = Double(nanoTime / 100) / 1_000_000.0
+    return elapsed
+  }
+  
   func handleMessage(_ message:String) {
     self.log("<< \(message.replacingOccurrences(of: "\t", with: " "))")
     let parts = message.components(separatedBy: "\t")

  }

  func sendMessage(id:String, message:String, data:String) {
    let queue = DispatchQueue(label: "org.webpagetest.message", attributes: .concurrent)
    queue.async {
      var str = id
      if str.characters.count > 0 {
        str += ":"
      }
      str += message
      if data.characters.count > 0 {
        str += "\t"
        str += data
      }
      str += "\n"
      self.sendMessageAsync(str)

}

class ViewController: UIViewController, WKNavigationDelegate {
  var startTime = DispatchTime.now()
  var webView: WKWebView?
  var clientSocket:Socket?
  var buffer_in = ""
