Runtime Code Coverage Tracking via Counter Maps

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Database management systems face challenges in optimizing performance due to complex queries and high transaction volumes, leading to complexities in developing and testing database management systems, where runtime-generated code often goes untested.

Innovation Solution

A method and system for measuring code coverage of runtime-generated code through a runtime framework that uses a map with counters to track execution, ensuring unit testing covers all lines of code, including generated code, by incrementing counters for each execution and providing verification.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Speed

If runtime-generated code is used to optimize database performance, then query execution speed is improved, but code coverage and testing reliability deteriorate because generated code is difficult to track and verify

Engineering Contradiction:
Improvequery execution speedVSAvoidcode coverage verification
Core Design Contradiction:
SpeedVSReliability

Solution Approach 1:

The patent introduces a map data structure as an intermediary between the runtime-generated code and the testing framework. This map stores mappings between code locations and counter identifiers, enabling the testing system to track execution of generated code without interfering with its performance optimization function. The intermediary translates runtime code execution into measurable test coverage data.

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The patent implements a feedback mechanism where counters associated with each code location are incremented during runtime execution, and the final counter values are retrieved after testing to determine code coverage. This feedback loop provides quantitative information about which generated code paths were executed, enabling verification of testing completeness while maintaining the performance benefits of runtime code generation.

Inventive Principle:
Principle #23Feedback

2Ease of operation

If traditional unit testing methods are used, then testing simplicity is maintained, but testing completeness deteriorates because runtime-generated code is not covered

Engineering Contradiction:
Improvetesting simplicityVSAvoidtesting completeness
Core Design Contradiction:
Ease of operationVSReliability

Solution Approach 1:

The patent performs preliminary actions by inserting counter initialization code and map population code during the code generation phase, before runtime execution begins. This preliminary setup ensures that counters are ready to track execution without requiring modifications to the testing framework or complex post-processing, maintaining testing simplicity while enabling comprehensive coverage tracking.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The map data structure serves as an intermediary that connects the generated code with the testing framework. By storing associations between code locations and counter identifiers in this map, the system enables automatic tracking of generated code execution without complicating the testing process. The intermediary handles the complexity of mapping generated code to test coverage metrics, preserving ease of operation.

Inventive Principle:
Principle #24Intermediary (Mediator)

3Measurement precision

If counters are inserted into generated code to track execution, then code coverage measurement is enabled, but generated code complexity increases

Engineering Contradiction:
Improvecode coverage measurementVSAvoidgenerated code complexity
Core Design Contradiction:
Measurement precisionVSDevice complexity

Solution Approach 1:

The patent extracts the measurement logic from the generated code by using external counters that are associated with code locations through a map data structure. Instead of embedding complex measurement mechanisms within the generated code itself, the system uses simple counter increment operations paired with location identifiers stored externally in the map. This separation reduces the complexity of generated code while maintaining precise measurement capability.

Inventive Principle:
Principle #2Taking out (Extraction)

Solution Approach 2:

The patent applies local quality by inserting minimal instrumentation code at specific locations in the generated code where execution tracking is needed. Rather than adding comprehensive logging or monitoring throughout the entire generated codebase, the system strategically places simple counter increment statements at key locations, maintaining measurement precision while minimizing the impact on generated code complexity.

Inventive Principle:
Principle #3Local quality

Data Source

PatentUS10713150B1Accurate test coverage of generated code
Publication Date: 2020.07.14 SAP SE
  • US10713150B1 patent drawing
  • US10713150B1 patent drawing
  • US10713150B1 patent drawing

AI summary

A method for measuring code coverage of runtime generated code is provided that can be used for unit testing. In some implementations, the method may include performing unit testing of one or more lines of code of an application by at least: executing during runtime the one or more lines of code, generating, from the executed one or more lines of code, additional code including generated code including instructions to increment at least one counter in a map, the map mapping one or more frames to the at least one counter, compiling the generated code, incrementing, each time the compiled generated code is executed during runtime, the at least one counter in the map, and providing the at least one counter to enable verification of the unit testing of the generated code. Related methods and articles of manufacture are also described.