public inbox for cocci@systeme.lip6.fr
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: Julia Lawall <julia.lawall@inria.fr>, cocci@inria.fr
Cc: "Derek M. Jones" <derek@knosof.co.uk>,
	Victor Gambier <victor.gambier@inria.fr>
Subject: Re: [cocci] Broken code block size determination in function implementations
Date: Tue, 29 Oct 2024 13:17:39 +0100	[thread overview]
Message-ID: <eeec899e-0510-4005-bd00-b65fbcba33a4@web.de> (raw)
In-Reply-To: <alpine.DEB.2.22.394.2410271803580.3498@hadrien>

> OK, that was much more understandable. …

I would like to add another development idea.


@initialize:python@
@@
import sys

records = {}

def store_data(places):
    """Add source code positions to an internal table."""
    for place in places:
       key = place.file, place.line, int(place.column) + 1

       if key in records:
          value = records[key]
          actions = value[0]
          actions.append(place.current_element)
          records[key] = actions, value[1]
       else:
          records[key] = [place.current_element], str(int(place.current_element_line_end) - int(place.line) - 1)


@searching@
identifier f;
position p;
@@
 f(...)
 {@p
 ...
 }

@script:python collection@
place << searching.p;
@@
store_data(place)

@finalize:python@
@@
if len(records) > 0:
   delimiter = "|"
   sys.stdout.write(delimiter.join(['action',
                                    '"block size"',
                                    '"source file"',
                                    '"block start line"',
                                    '"block start column"'
                                    ]))
   sys.stdout.write("\n")

   for key, value in records.items():
      sys.stdout.write(delimiter.join([str(value[0]),
                                       str(value[1]),
                                       key[0],
                                       key[1],
                                       str(key[2])
                                      ]))
      sys.stdout.write("\n")
else:
   sys.stderr.write("No result for this analysis!\n")


Test result:
Markus_Elfring@Sonne:…/Projekte/Linux/next-analyses> time spatch --python /usr/bin/python3 …/Projekte/Coccinelle/janitor/list_curly_bracket_positions_for_function_implementations7.cocci arch/sh/drivers/pci/common.c
…
action|"block size"|"source file"|"block start line"|"block start column"
['early_read_config_byte', 'early_read_config_dword', 'early_read_config_word', 'early_write_config_byte', 'early_write_config_dword', 'early_write_config_word']|3|arch/sh/drivers/pci/common.c|36|1
['fake_pci_dev']|17|arch/sh/drivers/pci/common.c|13|1
…
real    0m0,164s
user    0m0,133s
sys     0m0,028s


Would you be looking for more powerful computation resources if you would dare
to repeat the shown source code analysis approach with parallel data processing
on all Linux source files occasionally?

Would you become curious to take another look at the software run time characteristics
according to the biggest function implementations (which can be found also
by the means of the semantic patch language)?

Regards,
Markus

  parent reply	other threads:[~2024-10-29 12:18 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-24 11:56 [cocci] Multiple returns significant performance impact Derek M Jones
2024-10-24 12:42 ` Markus Elfring
2024-10-24 14:48 ` Julia Lawall
2024-10-24 15:23   ` Derek M Jones
2024-10-24 15:29     ` Julia Lawall
2024-10-24 15:35       ` Derek M Jones
2024-10-24 15:38         ` Julia Lawall
2024-10-24 15:44           ` Victor Gambier
2024-10-24 16:00             ` Julia Lawall
2024-10-24 15:50           ` Derek M Jones
2024-10-24 16:07             ` Markus Elfring
2024-10-24 16:14               ` Julia Lawall
2024-10-24 16:48             ` Markus Elfring
2024-10-24 17:30             ` Derek M Jones
2024-10-24 18:26               ` Markus Elfring
2024-10-24 21:03                 ` Derek M Jones
2024-10-25  5:38                   ` Markus Elfring
2024-10-25 11:54                     ` Derek M Jones
2024-10-27 12:48                     ` [cocci] Broken code block size determination in function implementations Markus Elfring
2024-10-27 13:31                       ` Julia Lawall
2024-10-27 15:15                         ` Markus Elfring
2024-10-27 16:40                         ` Markus Elfring
2024-10-27 17:05                           ` Julia Lawall
2024-10-27 17:28                             ` Markus Elfring
2024-10-27 17:34                               ` Julia Lawall
2024-10-27 17:45                                 ` Markus Elfring
2024-10-27 17:55                                   ` Julia Lawall
2024-10-27 18:04                                     ` Markus Elfring
2024-10-27 18:00                                   ` Derek M Jones
2024-10-27 18:11                                     ` [cocci] Evolving experiences from evidence-based software engineering Markus Elfring
2024-10-28  9:00                               ` [cocci] Searching for macro calls besides function implementations (with SmPL)? Markus Elfring
2024-10-28 12:57                                 ` Julia Lawall
2024-10-28 10:44                             ` [cocci] Broken code block size determination in function implementations Markus Elfring
2024-10-29 12:17                             ` Markus Elfring [this message]
2024-10-31  7:50                             ` Markus Elfring
2024-10-26 11:43             ` [cocci] Checking SmPL run time characteristics for code block position " Markus Elfring
2024-10-24 16:16           ` [cocci] SmPL position variables … Markus Elfring
2024-10-24 16:20             ` Julia Lawall
2024-10-24 16:28               ` Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=eeec899e-0510-4005-bd00-b65fbcba33a4@web.de \
    --to=markus.elfring@web.de \
    --cc=cocci@inria.fr \
    --cc=derek@knosof.co.uk \
    --cc=julia.lawall@inria.fr \
    --cc=victor.gambier@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox