comp.lang.ada
 help / color / mirror / Atom feed
From: joakimds@kth.se
Subject: Profiling Ada applications using gprof
Date: Tue, 4 Dec 2018 07:04:40 -0800 (PST)
Date: 2018-12-04T07:04:40-08:00	[thread overview]
Message-ID: <8441254e-f634-4077-b8d9-d988dab3406c@googlegroups.com> (raw)

Consider the following code:

with Ada.Text_IO;
procedure Main is

   task A is
      entry Stop;
   end A;
   
   task body A is
   begin
      select
         accept Stop do
            delay 10.0;
         end Stop;
      end select;
   end A;
   
   procedure Work is
   begin
      A.Stop;
   end Work;
   
begin
   Work;
   Ada.Text_IO.Put_Line ("Stopped");
end Main;

It is an application that takes 10.17 seconds to execute and "the problem" is the call A.Stop which takes too long (10 seconds) to return. The hope is to find this time consuming call with gprof.

The code is built with the file default.gpr:

project Default is
   for Source_Dirs use ("src");
   for Object_Dir use "obj";
   for Main use ("main.adb");
   
   package Compiler is

      for Switches ("Ada") use
        (
         "-g",
         "-pg"
        );
   
   end Compiler;
   
   package Linker is

      for Switches ("Ada") use
        (
         "-g",
         "-pg"
        );
   
   end Linker;
   
end Default;

Running the application creates a file gmon.out and running gprof on it and save the result in result.txt:
gprof --demangle=gnat main gmon.out > result.txt

Looking at the contents of result.txt:

Flat profile:

Each sample counts as 0.01 seconds.
 no time accumulated

  %   cumulative   self              self     total           
 time   seconds   seconds    calls  Ts/call  Ts/call  name    
  0.00      0.00     0.00        2     0.00     0.00  main
  0.00      0.00     0.00        1     0.00     0.00  <ada_main__Tsec_default_sized_stacksBIP>
  0.00      0.00     0.00        1     0.00     0.00  ada_main'Elab_Body
  0.00      0.00     0.00        1     0.00     0.00  ada_main.finalize_library
  0.00      0.00     0.00        1     0.00     0.00  adafinal
  0.00      0.00     0.00        1     0.00     0.00  adainit
  0.00      0.00     0.00        1     0.00     0.00  frame_dummy

...

		     Call graph (explanation follows)


granularity: each sample hit covers 2 byte(s) no time propagated

index % time    self  children    called     name
                0.00    0.00       1/1           ada_main'Elab_Body [2]
[1]      0.0    0.00    0.00       1         <ada_main__Tsec_default_sized_stacksBIP> [1]
-----------------------------------------------
                0.00    0.00       1/1           adainit [5]
[2]      0.0    0.00    0.00       1         ada_main'Elab_Body [2]
                0.00    0.00       1/1           <ada_main__Tsec_default_sized_stacksBIP> [1]
-----------------------------------------------
                0.00    0.00       1/1           system.tasking.stages.finalize_global_tasks [1193]
[3]      0.0    0.00    0.00       1         ada_main.finalize_library [3]
-----------------------------------------------
                0.00    0.00       1/1           main [456]
[4]      0.0    0.00    0.00       1         adafinal [4]
-----------------------------------------------
                0.00    0.00       1/1           main [456]
[5]      0.0    0.00    0.00       1         adainit [5]
                0.00    0.00       1/1           ada_main'Elab_Body [2]
-----------------------------------------------
                0.00    0.00       1/1           main [1278]
[6]      0.0    0.00    0.00       1         frame_dummy [6]
-----------------------------------------------
                                   4             main [1278]
                0.00    0.00       1/2           main [456]
                0.00    0.00       1/2           system.tasking.stages.task_wrapper [1196]
[1278]   0.0    0.00    0.00       2+4       main [1278]
                0.00    0.00       1/1           frame_dummy [6]
                                   4             main [1278]
-----------------------------------------------

As one can see there is nothing that indicates that something takes around 10 seconds to execute. Is it really impossible to detect the long running entry call A.Stop?

Best regards,
Joakim


             reply	other threads:[~2018-12-04 15:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-04 15:04 joakimds [this message]
2018-12-04 19:41 ` Profiling Ada applications using gprof Dennis Lee Bieber
2018-12-05 14:13 ` Petter Fryklund
2018-12-05 15:32   ` joakimds
2018-12-05 16:05     ` joakimds
2018-12-05 17:27       ` Dmitry A. Kazakov
2018-12-05 20:11   ` Dennis Lee Bieber
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox