IP Library › Granted Patent US 12,675,267
Granted Patent B2
US 12,675,267 · App. 18/510,627 · Granted Jul 7, 2026

Program code optimization using iterative application of machine learning model

Inventors: Don Cowan (San Francisco, CA); Jesus Manuel Olivera (New York, NY); Brian Scott Paskin (Somerville, MA); Hicham Badawi (Austin, TX)
Assignee: International Business Machines Corporation
G06F8/443G06F40/20
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12,675,267
App. No.
18/510,627
Filed
Nov 15, 2023
Granted
Jul 7, 2026
Kind
B2
Art Unit
2193
USPC
717/151
Abstract

A computing device may insert a library function into a set of code. The computing device may use the library function to capture one or more metrics associated with execution of the set of code in a testing environment. The computing device may evaluate the processing times to identify a portion of the set of code with a processing time that is highest compared to processing times of other portions of the set of code. The computing device may subdivide the portion of the set of code into subdivided portions of the set of code. The computing device may train a machine learning model, utilizing the subdivided portions of the set of code, to obtain a trained model. The computing device may recommend, using the trained machine learning model, optimization code to improve the processing time as the set of code is modified.

Claims (66)

1 . A computer-implemented method for optimizing computer code, the computer-implemented method comprising:

modifying a set of code by inserting a library function into the set of code;

executing, in a testing environment, the set of code with the library function;

capturing, using the library function, one or more metrics associated with execution of the set of code in the testing environment,

the one or more metrics being captured during the execution of the set of code;

iteratively analyzing the set of code to identify, based on the one or more metrics, a portion of the set of code with a processing time that is highest compared to processing times of other portions of the set of code,

the portion of the set of code being identified to improve processing times of the set of code;

iteratively training a machine learning model, utilizing training data associated with the set of code, to obtain a trained machine learning model; and

iteratively recommending, using the trained machine learning model, optimization code to improve the processing time as the set of code is being modified,

wherein iteratively recommending the optimization code comprises generating the optimization code.

2 . The computer-implemented method of claim 1 , wherein inserting the library function comprises:

wrapping the set of code into library code of the library function by:

inserting a first portion of the library code prior to the set of code, and

inserting a second portion of the library code after the set of code.

3 . The computer-implemented method of claim 1 , wherein iteratively recommending the optimization code comprises:

generating a recommendation, for the optimization code, using stepwise refinements to identify the optimization code that reduces the processing time.

4 . The computer-implemented method of claim 1 , wherein iteratively recommending the improvement code comprises:

generating, using a large language model, optimization code to replace the set of code.

5 . The computer-implemented method of claim 1 , wherein training the machine learning model comprises:

training a large language model utilizing the subdivided portions of the code.

6 . The computer-implemented method of claim 1 , wherein identifying a portion of the set of code comprises:

identifying a code loop.

7 . The computer-implemented method of claim 1 , wherein identifying a portion of the set of code comprises:

identifying a machine learning inference.

8 . A computer program product comprising:

one or more computer readable storage media, and program instructions collectively stored on the one or more computer readable storage media, the program instructions comprising:

program instructions to modify a set of code by inserting performance monitoring code of a library function into the set of code running in a testing environment;

program instructions to execute the set of code;

program instructions to capture, using the performance monitoring code, performance metrics associated with execution of the set of code;

program instructions to iteratively analyze a plurality of code blocks of the set of code identify, based on the performance metrics, a code block, of the plurality of code blocks, with a processing time that is highest among processing times of the plurality of code blocks,

the plurality of code blocks being iteratively analyzed to improve a processing time of the set of code;

program instructions to iteratively train a machine learning model, utilizing training data associated with the set of code, to obtain a trained machine learning model; and

program instructions to generate, using the trained machine learning model, optimization code to improve the processing time of the set of code.

9 . The computer program product of claim 8 , wherein the program instructions to generate the recommendation comprise:

program instructions to generate, using a large language model, the optimization code to replace the set of code.

10 . The computer program product of claim 8 , wherein the program instructions to generate the recommendation comprise:

program instructions to generate the optimization code using stepwise refinements to reduce the processing time of the set of code.

11 . The computer program product of claim 8 , wherein the program instructions to capture the performance metrics comprise:

program instructions to obtain processing time data per lines of the set of code.

12 . The computer program product of claim 8 , wherein the set of code is a first set of code,

wherein the machine learning model is trained using the training data, that includes the first set of code, to generate recommendations to reduce processing times for code associated with the first set of code, and

wherein the program instructions further comprise program instructions to generate, using the trained machine learning model, a recommendation for a second set of code to reduce a processing time of the second set of code.

13 . The computer program product of claim 8 , wherein the processing time includes a processing time used by an application software associated with the set of code.

14 . The computer program product of claim 8 , wherein the processing time includes a processing time used by an operating system associated with the set of code.

15 . The computer program product of claim 8 , wherein the performance metrics include the processing time, a memory usage, and a central processing unit usage.

16 . A system comprising:

one or more devices configured to:

modify a set of code by inserting performance monitoring code into a set of code;

execute the set of code with the performance monitoring code;

capture, using the performance monitoring code, performance metrics associated with execution of the set of code;

iteratively analyze a plurality of code blocks of the set of code to identify, based on the performance metrics, a code block, of the plurality of code blocks, with a processing time that is highest among processing times of the plurality of code blocks,

the plurality of code blocks being iteratively analyzed to reduce processing times of the set of code;

iteratively train a machine learning model, utilizing training data associated with the set of code, to obtain a trained machine learning model;

iteratively generate, using the trained machine learning model, optimization code that reduces the processing time; and

cause the optimization code to replace the set of code to reduce the processing time.

17 . The system of claim 16 , wherein the processing time includes a clock time used by an application software associated with the set of code.

18 . The system of claim 16 , wherein the machine learning model includes a large language model, and

wherein the one or more devices are further configured:

generate, using the large language model, a recommendation to divide the set of code to reduce the processing time.

19 . The system of claim 18 , wherein the one or more devices, to generate the optimization code, are further configured to:

generate, using the large language model, the optimization code to replace the set of code.

20 . The system of claim 16 , wherein the one or more devices are further configured to:

store the code block and the performance metrics in a data repository;

obtain the code block and the performance metrics from the data repository; and

train the machine learning model, using the code block and the performance metrics obtained from the data repository, to obtain the trained machine learning model,

wherein the trained machine language model is trained to predict improvements to code.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Nov 15, 2023
From: COWAN, DON; OLIVERA, JESUS MANUEL; PASKIN, BRIAN SCOTT; BADAWI, HICHAM
To: INTERNATIONAL BUSINESS MACHINES CORPORATION
Reel/Frame 065578/0056 →
Continuity (1)
Related Publication 20250156161A1 · May 15, 2025
References Cited (38)
US 8799693B2 · Vick et al. · 2014 [cited by applicant]
US 9483295B2 · Gschwind · 2016 [cited by applicant]
US 9977439B2 · Park et al. · 2018 [cited by applicant]
US 10474455B2 · Makkar · 2019 [cited by examiner]
US 10481879B2 · Stevens · 2019 [cited by applicant]
US 10635409B2 · Pradhan · 2020 [cited by applicant]
US 11579868B1 · Zhang · 2023 [cited by applicant]
US 11604642B2 · Jayapandy · 2023 [cited by applicant]
US 12288045B2 · Verma · 2025 [cited by examiner]
US 20060001044A1 · Yamada et al. · 2006 [cited by applicant]
US 20060010441A1 · Hisashi · 2006 [cited by applicant]
US 20060101440A1 · Stay et al. · 2006 [cited by applicant]
US 20100042976A1 · Hines · 2010 [cited by applicant]
US 20100180255A1 · Chung · 2010 [cited by applicant]
US 20150379429A1 · Lee · 2015 [cited by examiner]
US 20170212829A1 · Bales · 2017 [cited by applicant]
US 20190220253A1 · Pradhan et al. · 2019 [cited by applicant]
US 20190243617A1 · Stevens et al. · 2019 [cited by applicant]
US 20200356901A1 · Zarandioon · 2020 [cited by examiner]
US 20210182039A1 · Cappello · 2021 [cited by examiner]
US 20220027134A1 · Ivankovic · 2022 [cited by applicant]
US 20220129254A1 · Chang · 2022 [cited by applicant]
US 20220214874A1 · Jayapandy et al. · 2022 [cited by applicant]
US 20230108808A1 · Lerman · 2023 [cited by examiner]
US 20230128680A1 · Carranza · 2023 [cited by examiner]
US 20250036377A1 · Verma · 2025 [cited by examiner]
Wang, Song, et al. “Automatic unit test generation for machine learning libraries: How far are we?.” 2021 IEEE/ACM 43rd International Conference on Software Engineering (ICSE). IEEE, 2021. pp. 1548-1560 (Year: 2021). [cited by examiner]
Medeiros, Nadia, et al. “Vulnerable code detection using software metrics and machine learning.” IEEE Access 8 (2020): pp. 219174-219198. (Year: 2020). [cited by examiner]
Dutta, Saikat, et al. “Tera: Optimizing stochastic regression tests in machine learning projects.” Proceedings of the 30th ACM SIGSOFT International Symposium on Software Testing and Analysis. 2021. pp. 413-426 (Year: 2… [cited by examiner]
Stephenson, Mark, et al. “Meta optimization: Improving compiler heuristics with machine learning.” ACM sigplan notices 38.5 (2003): pp. 77-90. (Year: 2003). [cited by examiner]
Dehaerne, Enrique, et al. “Code generation using machine learning: A systematic review.” Ieee Access 10 (2022): pp. 82434-82455. (Year: 2022). [cited by examiner]
Le, Triet HM, Hao Chen, and Muhammad Ali Babar. “Deep learning for source code modeling and generation: Models, applications, and challenges.” ACM Computing Surveys (CSUR) 53.3 (2020): pp. 1-38. (Year: 2020). [cited by examiner]
Natalia Szydlowska, Green Software Development:Energy Efficient Programming Languages, Tools and Practices in Coding, online article, Sep. 19, 2022, pp. 2-17, retrieved from https://betterprogramming.pub/thinking-about-… [cited by applicant]
Green coding: A sustainability practice all software engineers should adhere to, Jun. 8, 2023, pp. 1-2, https://curiosum.com/blog/green-coding-software-development-energy-efficient-programming-languages, on Jun. 8, 2023. [cited by applicant]
Johanne Andersen, Thinking about Software Sustainably, online article, Jun. 15, 2020, pp. 1-7, Better Programming, retrieved from https://www.computerweekly.com/blog/Green-Tech/Green-coding-A-sustainability-practice-all… [cited by applicant]
Geeksforgeeks, How to measure time taken by a function in C, online article, Jun. 21, 2022, pp. 1-6, retrieved from https://www.geeksforgeeks.org/how-to-measure-time-taken-by-a-program-in-c/, on Jun. 8, 2023. [cited by applicant]
Tutorialsteacher, How to calculate the code execution time in C#, Jun. 8, 2023, online article, pp. 1-5, retrieved from https://www.tutorialspoint.com/how-to-measure-execution-time-for-a-java-method on Jun. 8, 2023. [cited by applicant]
Tutorialspoint, How to measure execution, time for a java method, online article, Jun. 8, 2023, online article, pp. 1-2, retrieved from https://www.tutorialspoint.com/how-to-measure-execution-time-for-a-java-method on J… [cited by applicant]