You are right.  Here's an updated version of the app that take into account
the time before Main::main() is invoked.

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.*;

public class Main extends Application {
    private static long t0;
    private static long t1;
    private static long t2;
    private static long t3;
    private static long t4;

    public void start(Stage stage) {
        t2 = System.currentTimeMillis();
        Label l0 = new Label("java: " + t0);
        Label l1 = new Label("main: " + (t1 - t0));
        Label l2 = new Label("start: " + (t2 - t1) + ", " + (t2 - t0));
        Label l3 = new Label("");
        Label l4 = new Label("");
        VBox vbox = new VBox(l0, l1, l2, l3, l4);
        Scene scene = new Scene(vbox);
        stage.setScene(scene);
        stage.setTitle("Timing Demo");
        stage.setOnShowing(e -> {
            t3 = System.currentTimeMillis();
            l3.setText("showing: " + (t3 - t2) + ", " + (t3 - t0));
        });
        stage.setOnShown(e -> {
            t4 = System.currentTimeMillis();
            l4.setText("shown: " + (t4 - t3) + ", " + (t4 - t0));
        });
        stage.show();
    }

    public static void main(String[] args) {
        t0 = Long.parseLong(args[0])/1000000;
        t1 = System.currentTimeMillis();
        launch(args);
    }
}

Invoke it with the command line

    java Main `date +%s%N`

This seems to add 500 milliseconds to the time.  A screenshot is attached.

If I go really minimalist and not do all the Labels, and print the numbers
to the console instead, the number goes down to 750-800: 787, 782, 778,
790, 748, 747, 777, 775, 763, 785.

Here's one of those invocations:

$ java Main1 `date +%s%N`
1528225502595
494
519
658
785

Beat Regards,
--
Weiqi Gao
weiqi...@gmail.com

On Tue, Jun 5, 2018 at 12:53 PM, Mario Ivankovits <ma...@datenwort.at>
wrote:

> Hi!
>
> Just for the records: My test included the JVM startup time. Yours start
> counting in main() where the JVM is already up - and probably some of the
> classpath scanning already took place because of the inheritance from
> „javafx.application.Application“ .
> Your test shows „showing: 298 shown: 468“ on my machine.
>
> A „native“ splash screen usually should start up at the very first, before
> the JVM starts.
>
>
> Best regards,
> Mario
>
>
> > Am 05.06.2018 um 19:04 schrieb Weiqi Gao <weiqi...@gmail.com>:
> >
> > Here's a more accurate (but still rough) timing application:
> >
> > import javafx.application.Application;
> > import javafx.stage.Stage;
> > import javafx.scene.Scene;
> > import javafx.scene.control.*;
> > import javafx.scene.layout.*;
> >
> > public class Main extends Application {
> >    private static long t1;
> >    private static long t2;
> >    private static long t3;
> >    private static long t4;
> >
> >    public void start(Stage stage) {
> >        t2 = System.currentTimeMillis();
> >        Label l1 = new Label("main:    " + t1);
> >        Label l2 = new Label("start:   " + (t2 - t1));
> >        Label l3 = new Label("");
> >        Label l4 = new Label("");
> >        VBox vbox = new VBox(l1, l2, l3, l4);
> >        Scene scene = new Scene(vbox);
> >        stage.setScene(scene);
> >        stage.setTitle("Timing Demo");
> >        stage.setOnShowing(e -> {
> >            t3 = System.currentTimeMillis();
> >            l3.setText("showing: " + (t3 - t2) + ", " + (t3 - t1));
> >        });
> >        stage.setOnShown(e -> {
> >            t4 = System.currentTimeMillis();
> >            l4.setText("shown:   " + (t4 - t3) + ", " + (t4 - t1));
> >        });
> >        stage.show();
> >    }
> >
> >    public static void main(String[] args) {
> >        t1 = System.currentTimeMillis();
> >        launch(args);
> >    }
> > }
> >
> > The result of running it on my Dell laptop with Intel Core i7-6820HQ
> > @2.70GHz,CPU and NVIDIA Quadro M1000M display adapter is attached:
> >
> > Essentially, it took less than half a second for a dead simple JavaFX
> Stage
> > to be visible.
> >
> > Here's the timing number for 10 consecutive runs: 422, 440, 426, 442,
> 418,
> > 441, 432, 444, 470, 453
> >
> > --
> > Weiqi Gao
> > weiqi...@gmail.com
> >
> > On Tue, Jun 5, 2018 at 10:46 AM, Scott Palmer <swpal...@gmail.com>
> wrote:
> >
> >> Yes, my only comment was that if we can get a window up using standard
> Java
> >> GUI frameworks fast enough, then the complexity of adding splashscreen
> >> support to the launcher isn't justified.
> >> Mario's example shows that is it 1-2 seconds to get a window up.  That
> is a
> >> bit high.  If it was under 1s then I would suggest not bothering, it
> isn't,
> >> so keep it on the list of desired features.
> >>
> >> Scott
> >>
> >> On Tue, Jun 5, 2018 at 8:21 AM Pedro Duque Vieira <
> >> pedro.duquevie...@gmail.com> wrote:
> >>
> >>> Sorry, perhaps it was I who misunderstood the debate..
> >>>
> >>> On Mon, Jun 4, 2018 at 4:06 PM, Michael Paus <m...@jugs.org> wrote:
> >>>
> >>>> Maybe I misunderstood the question but to my opinion the real question
> >> is
> >>>> whether the new java packager has to provide the support for a splash
> >>>> screen
> >>>> or not. This has nothing to do with the question whether applications
> >>>> should
> >>>> have a splash screen or not because if we find that todays Java is
> fast
> >>>> enough
> >>>> to display a simple window in less than a second or so, then the Java
> >> GUI
> >>>> (Swing or JavaFX) could provide a splash screen itself. There is then
> >> no
> >>>> need
> >>>> for an additional mechanism provided my the packager.
> >>>>
> >>>> Am 04.06.18 um 16:44 schrieb Pedro Duque Vieira:
> >>>>
> >>>> Hi,
> >>>>>
> >>>>> I agree with Johan and others, a splash screen is valuable and
> needed.
> >>>>>
> >>>>> Microsoft applications that run on Windows itself (think Word, Excel,
> >>>>> etc),
> >>>>> they have a splash screen, Intelllij has a splash screen (it's swing
> >>> based
> >>>>> AFAIK), etc.. If a Microsoft application running on its own operating
> >>>>> system needs a splash screen then chances are pretty high that there
> >>> will
> >>>>> be Java apps that'll need a splash screen.
> >>>>>
> >>>>> Cheers,
> >>>>>
> >>>>>
> >>>>>
> >>>>
> >>>
> >>>
> >>> --
> >>> Pedro Duque Vieira
> >>>
> >>
> >
> >
> >
> > --
> > Weiqi Gao (高为奇)
> > weiqi...@gmail.com
> > http://weiqigao.blogspot.com/
>
>


-- 
Weiqi Gao (高为奇)
weiqi...@gmail.com
http://weiqigao.blogspot.com/

Reply via email to