Example usage for com.vaadin.client Profiler getRelativeTimeMillis

List of usage examples for com.vaadin.client Profiler getRelativeTimeMillis

Introduction

In this page you can find the example usage for com.vaadin.client Profiler getRelativeTimeMillis.

Prototype

public static double getRelativeTimeMillis() 

Source Link

Document

Returns time relative to the particular page load time.

Usage

From source file:com.haulmont.cuba.web.toolkit.ui.client.communication.CubaXhrConnection.java

License:Apache License

@Override
protected XhrResponseHandler createResponseHandler() {
    return new XhrResponseHandler() {
        protected int serverTimeOnClient;

        @Override/*from   w w  w  .  j ava  2 s.c  om*/
        public void onResponseReceived(Request request, Response response) {
            int statusCode = response.getStatusCode();
            if (statusCode == 200) {
                serverTimeOnClient = (int) Util.round(Profiler.getRelativeTimeMillis() - requestStartTime, 0);
            }
            super.onResponseReceived(request, response);
        }

        @Override
        protected void beforeHandlingMessage(ValueMap json) {
            super.beforeHandlingMessage(json);
            ScreenClientProfiler profiler = ScreenClientProfiler.getInstance();
            String profilerMarker = ScreenClientProfiler.getProfilerMarkerFromJson(json);
            if (profilerMarker != null) {
                int serverTimeOnServer = ScreenClientProfiler.getServerTimeFromJson(json);
                if (serverTimeOnServer > 0) {
                    profiler.registerServerTime(profilerMarker, serverTimeOnServer);
                    profiler.registerNetworkTime(profilerMarker, serverTimeOnClient - serverTimeOnServer);
                } else {
                    profiler.registerServerTime(profilerMarker, serverTimeOnClient);
                }
                profiler.registerEventTs(profilerMarker, ScreenClientProfiler.getEventTsFromJson(json));
            }
        }
    };
}