File: CMakeLists.txt

package info (click to toggle)
llvm-toolchain-21 1%3A21.1.6-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,245,028 kB
  • sloc: cpp: 7,619,726; ansic: 1,434,018; asm: 1,058,748; python: 252,740; f90: 94,671; objc: 70,685; lisp: 42,813; pascal: 18,401; sh: 8,601; ml: 5,111; perl: 4,720; makefile: 3,675; awk: 3,523; javascript: 2,409; xml: 892; fortran: 770
file content (49 lines) | stat: -rw-r--r-- 2,012 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# =================================================================================
# Lifetime Analysis Benchmarking Target
# =================================================================================
# This target allows running performance benchmarks for the clang lifetime analysis
# using a Python script (with managed dependencies).

find_package(Python3 COMPONENTS Interpreter REQUIRED)

# Define paths for the virtual environment and requirements file.
set(LIFETIME_BENCHMARK_SCRIPT 
  "${CMAKE_CURRENT_SOURCE_DIR}/benchmark.py")
set(LIFETIME_BENCHMARK_VENV_DIR "${CMAKE_CURRENT_BINARY_DIR}/benchmark-venv")
set(LIFETIME_BENCHMARK_REQUIREMENTS
  "${CMAKE_CURRENT_SOURCE_DIR}/requirements.txt")
set(LIFETIME_BENCHMARK_OUTPUT_DIR
  "${CMAKE_CURRENT_BINARY_DIR}/benchmark_results")


if(EXISTS ${LIFETIME_BENCHMARK_SCRIPT} AND EXISTS ${LIFETIME_BENCHMARK_REQUIREMENTS})

  # Set up the virtual environment and install packages
  add_custom_command(
    OUTPUT ${LIFETIME_BENCHMARK_VENV_DIR}/pyvenv.cfg
    COMMAND ${Python3_EXECUTABLE} -m venv ${LIFETIME_BENCHMARK_VENV_DIR}
    COMMAND ${LIFETIME_BENCHMARK_VENV_DIR}/bin/python -m pip install -r ${LIFETIME_BENCHMARK_REQUIREMENTS}
    DEPENDS ${LIFETIME_BENCHMARK_REQUIREMENTS}
    COMMENT "Creating Python virtual environment and installing dependencies for benchmark..."
  )
  add_custom_target(benchmark_venv_setup
    DEPENDS ${LIFETIME_BENCHMARK_VENV_DIR}/pyvenv.cfg
  )

  # Main benchmark target
  add_custom_target(benchmark_lifetime_safety_analysis
    COMMAND ${LIFETIME_BENCHMARK_VENV_DIR}/bin/python ${LIFETIME_BENCHMARK_SCRIPT}
            --clang-binary ${LLVM_BINARY_DIR}/bin/clang
            --output-dir ${LIFETIME_BENCHMARK_OUTPUT_DIR}

    DEPENDS clang benchmark_venv_setup

    # Display the output directly in the console.
    USES_TERMINAL
    
    COMMENT "Running Lifetime Analysis performance benchmarks..."
  )

  set_target_properties(benchmark_lifetime_safety_analysis 
    PROPERTIES FOLDER "Clang/Benchmarks")
endif()