funcprofiler 1.0.1__tar.gz → 1.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: funcprofiler
3
- Version: 1.0.1
3
+ Version: 1.0.2
4
4
  Summary: An open-source Python library for finding bottlenecks in code. Includes function profiling, data exports, logging, and even line-by-line profiling, for more control.
5
- Home-page: https://github.com/infinitode/valx
5
+ Home-page: https://github.com/infinitode/funcprofiler
6
6
  Author: Infinitode Pty Ltd
7
7
  Author-email: infinitode.ltd@gmail.com
8
8
  Classifier: Development Status :: 5 - Production/Stable
@@ -15,12 +15,21 @@ Classifier: Programming Language :: Python :: 3.9
15
15
  Classifier: Programming Language :: Python :: 3.10
16
16
  Classifier: Programming Language :: Python :: 3.11
17
17
  Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
18
19
  Requires-Python: >=3.6
19
20
  Description-Content-Type: text/markdown
20
21
  License-File: LICENSE
22
+ Dynamic: author
23
+ Dynamic: author-email
24
+ Dynamic: classifier
25
+ Dynamic: description
26
+ Dynamic: description-content-type
27
+ Dynamic: home-page
28
+ Dynamic: requires-python
29
+ Dynamic: summary
21
30
 
22
31
  # FuncProfiler
23
- ![Python Version](https://img.shields.io/badge/python-3.12-blue.svg)
32
+ ![Python Version](https://img.shields.io/badge/python-3.13-blue.svg)
24
33
  [![Code Size](https://img.shields.io/github/languages/code-size/infinitode/funcprofiler)](https://github.com/infinitode/funcprofiler)
25
34
  ![Downloads](https://pepy.tech/badge/funcprofiler)
26
35
  ![License Compliance](https://img.shields.io/badge/license-compliance-brightgreen.svg)
@@ -28,6 +37,9 @@ License-File: LICENSE
28
37
 
29
38
  An open-source Python library for identifying bottlenecks in code. It includes function profiling, data exports, logging, and line-by-line profiling for more granular control.
30
39
 
40
+ ## Changelog (v.1.0.2):
41
+ - Added support for 2 new export formats: `xml` and `md` in both function profiling, and line-by-line profiling.
42
+
31
43
  ## Installation
32
44
 
33
45
  You can install FuncProfiler using pip:
@@ -54,7 +66,7 @@ Please ensure that you have one of these Python versions installed. FuncProfiler
54
66
  - **Function Profiling**: Monitor a function's memory usage and execution time to identify performance issues.
55
67
  - **Line-by-Line Profiling**: Return execution time and memory usage for each line of any given function.
56
68
  - **Shared Logging**: Log outputs of functions triggered by the line-by-line and function profilers, storing results in a `.txt` file.
57
- - **File Exports**: Export profiling data from functions in `csv`, `json`, or `html` formats.
69
+ - **File Exports**: Export profiling data from functions in `csv`, `json`, `html`, `xml` and `md` formats, for both line-by-line profiling and function profiling.
58
70
  > [!NOTE]
59
71
  > View more export types in the [official documentation](https://infinitode-docs.gitbook.io/documentation/package-documentation/funcprofiler-package-documentation).
60
72
 
@@ -1,5 +1,5 @@
1
1
  # FuncProfiler
2
- ![Python Version](https://img.shields.io/badge/python-3.12-blue.svg)
2
+ ![Python Version](https://img.shields.io/badge/python-3.13-blue.svg)
3
3
  [![Code Size](https://img.shields.io/github/languages/code-size/infinitode/funcprofiler)](https://github.com/infinitode/funcprofiler)
4
4
  ![Downloads](https://pepy.tech/badge/funcprofiler)
5
5
  ![License Compliance](https://img.shields.io/badge/license-compliance-brightgreen.svg)
@@ -7,6 +7,9 @@
7
7
 
8
8
  An open-source Python library for identifying bottlenecks in code. It includes function profiling, data exports, logging, and line-by-line profiling for more granular control.
9
9
 
10
+ ## Changelog (v.1.0.2):
11
+ - Added support for 2 new export formats: `xml` and `md` in both function profiling, and line-by-line profiling.
12
+
10
13
  ## Installation
11
14
 
12
15
  You can install FuncProfiler using pip:
@@ -33,7 +36,7 @@ Please ensure that you have one of these Python versions installed. FuncProfiler
33
36
  - **Function Profiling**: Monitor a function's memory usage and execution time to identify performance issues.
34
37
  - **Line-by-Line Profiling**: Return execution time and memory usage for each line of any given function.
35
38
  - **Shared Logging**: Log outputs of functions triggered by the line-by-line and function profilers, storing results in a `.txt` file.
36
- - **File Exports**: Export profiling data from functions in `csv`, `json`, or `html` formats.
39
+ - **File Exports**: Export profiling data from functions in `csv`, `json`, `html`, `xml` and `md` formats, for both line-by-line profiling and function profiling.
37
40
  > [!NOTE]
38
41
  > View more export types in the [official documentation](https://infinitode-docs.gitbook.io/documentation/package-documentation/funcprofiler-package-documentation).
39
42
 
@@ -7,13 +7,14 @@ import sys
7
7
  import csv
8
8
  import json
9
9
  from typing import Callable, List, Dict, Optional
10
+ import xml.etree.ElementTree as ET
10
11
 
11
12
  __all__ = ['function_profile', 'line_by_line_profile', 'export_function_profile_data', 'export_profiling_data']
12
13
 
13
14
  def function_profile(export_format: Optional[str] = None, filename: Optional[str] = None, shared_log: bool = False) -> Callable:
14
15
  """Decorator factory to profile the execution time and memory usage of a function.
15
16
 
16
- Args:
17
+ Parameters:
17
18
  export_format (Optional[str]): The format to export the profiling data ('txt', 'json', 'csv', 'html').
18
19
  filename (Optional[str]): The name of the output file (without extension).
19
20
  shared_log (Optional[bool]): If True, log to a shared file for all profiled functions.
@@ -78,10 +79,10 @@ def function_profile(export_format: Optional[str] = None, filename: Optional[str
78
79
  def export_function_profile_data(profiling_data: dict, func: Callable, export_format: str, filename: str) -> None:
79
80
  """Export profiling data for the function profile to the specified format.
80
81
 
81
- Args:
82
+ Parameters:
82
83
  profiling_data (dict): The profiling data containing execution time and memory usage.
83
84
  func (Callable): The function that was profiled.
84
- export_format (str): The format for export ('txt', 'json', 'csv', 'html').
85
+ export_format (str): The format for export ('txt', 'json', 'csv', 'html', 'xml', 'md').
85
86
  filename (str): The output filename without extension.
86
87
  """
87
88
  execution_time = profiling_data["execution_times"]
@@ -115,8 +116,22 @@ def export_function_profile_data(profiling_data: dict, func: Callable, export_fo
115
116
  f.write(f"<p>Memory Usage: <strong>{memory_usage:.6f}MB</strong></p>")
116
117
  f.write("</body></html>")
117
118
 
119
+ elif export_format == "xml":
120
+ root = ET.Element("FunctionProfile")
121
+ ET.SubElement(root, "Function").text = func.__name__
122
+ ET.SubElement(root, "ExecutionTime").text = f"{execution_time:.12f}"
123
+ ET.SubElement(root, "MemoryUsage").text = f"{memory_usage:.6f}"
124
+ tree = ET.ElementTree(root)
125
+ tree.write(f"{filename}.xml")
126
+
127
+ elif export_format == "md":
128
+ with open(f"{filename}.md", 'w') as f:
129
+ f.write(f"# Function Profiling Report for {func.__name__}\n\n")
130
+ f.write(f"**Execution Time:** {execution_time:.12f}s\n\n")
131
+ f.write(f"**Memory Usage:** {memory_usage:.6f}MB\n")
132
+
118
133
  else:
119
- raise ValueError("Unsupported export format. Use 'txt', 'json', 'csv', or 'html'.")
134
+ raise ValueError("Unsupported export format. Use 'txt', 'json', 'csv', 'html', 'xml', or 'md'.")
120
135
 
121
136
  def line_by_line_profile(
122
137
  export_format: Optional[str] = None,
@@ -125,7 +140,7 @@ def line_by_line_profile(
125
140
  ) -> Callable:
126
141
  """Decorator for line-by-line profiling of a function with optional data export and shared logging.
127
142
 
128
- Args:
143
+ Parameters:
129
144
  export_format (Optional[str]): The format to export the profiling data ('json', 'csv', 'html').
130
145
  filename (Optional[str]): The name of the output file (without extension).
131
146
  shared_log (Optional[bool]): If True, log to a shared file for all profiled functions.
@@ -227,12 +242,12 @@ def export_profiling_data(
227
242
  export_format: str,
228
243
  filename: str
229
244
  ) -> None:
230
- """Export the profiling data to the specified format (JSON, CSV, HTML).
245
+ """Export the profiling data to the specified format (JSON, CSV, HTML, XML, MD).
231
246
 
232
- Args:
247
+ Parameters:
233
248
  profiling_data (Dict[str, Dict[int, float]]): Profiling data to be exported.
234
249
  func (Callable): The function that was profiled.
235
- export_format (str): The format for export ('json', 'csv', 'html').
250
+ export_format (str): The format for export ('json', 'csv', 'html', 'xml', 'md').
236
251
  filename (str): The output filename without extension.
237
252
  """
238
253
  line_execution_times = profiling_data["line_execution_times"]
@@ -332,5 +347,28 @@ def export_profiling_data(
332
347
  f.write(html_content)
333
348
  print(f"[PROFILER] HTML report generated at: {output_path}")
334
349
 
350
+ elif export_format == 'xml':
351
+ root = ET.Element("FunctionProfile")
352
+ for data in export_data:
353
+ line_element = ET.SubElement(root, "Line")
354
+ ET.SubElement(line_element, "FunctionName").text = data['Function Name']
355
+ ET.SubElement(line_element, "LineNumber").text = data['Line Number']
356
+ ET.SubElement(line_element, "SourceCode").text = data['Source Code']
357
+ ET.SubElement(line_element, "ExecutionTime").text = data['Execution Time (s)']
358
+ ET.SubElement(line_element, "MemoryUsage").text = data['Memory Usage (MB)']
359
+ tree = ET.ElementTree(root)
360
+ tree.write(f"{filename}.xml")
361
+ print(f"[PROFILER] XML report generated at: {filename}.xml")
362
+
363
+ elif export_format == 'md':
364
+ output_path = f"{filename}.md"
365
+ with open(output_path, 'w') as f:
366
+ f.write(f"# Line-by-Line Profiling Report for {func.__name__}\n\n")
367
+ f.write("| Line Number | Source Code | Execution Time (s) | Memory Usage (MB) |\n")
368
+ f.write("|-------------|-------------|--------------------|-------------------|\n")
369
+ for data in export_data:
370
+ f.write(f"| {data['Line Number']} | {data['Source Code']} | {data['Execution Time (s)']} | {data['Memory Usage (MB)']} |\n")
371
+ print(f"[PROFILER] Markdown report generated at: {output_path}")
372
+
335
373
  else:
336
374
  print(f"[PROFILER] Unsupported export format: {export_format}")
@@ -1,8 +1,8 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: funcprofiler
3
- Version: 1.0.1
3
+ Version: 1.0.2
4
4
  Summary: An open-source Python library for finding bottlenecks in code. Includes function profiling, data exports, logging, and even line-by-line profiling, for more control.
5
- Home-page: https://github.com/infinitode/valx
5
+ Home-page: https://github.com/infinitode/funcprofiler
6
6
  Author: Infinitode Pty Ltd
7
7
  Author-email: infinitode.ltd@gmail.com
8
8
  Classifier: Development Status :: 5 - Production/Stable
@@ -15,12 +15,21 @@ Classifier: Programming Language :: Python :: 3.9
15
15
  Classifier: Programming Language :: Python :: 3.10
16
16
  Classifier: Programming Language :: Python :: 3.11
17
17
  Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
18
19
  Requires-Python: >=3.6
19
20
  Description-Content-Type: text/markdown
20
21
  License-File: LICENSE
22
+ Dynamic: author
23
+ Dynamic: author-email
24
+ Dynamic: classifier
25
+ Dynamic: description
26
+ Dynamic: description-content-type
27
+ Dynamic: home-page
28
+ Dynamic: requires-python
29
+ Dynamic: summary
21
30
 
22
31
  # FuncProfiler
23
- ![Python Version](https://img.shields.io/badge/python-3.12-blue.svg)
32
+ ![Python Version](https://img.shields.io/badge/python-3.13-blue.svg)
24
33
  [![Code Size](https://img.shields.io/github/languages/code-size/infinitode/funcprofiler)](https://github.com/infinitode/funcprofiler)
25
34
  ![Downloads](https://pepy.tech/badge/funcprofiler)
26
35
  ![License Compliance](https://img.shields.io/badge/license-compliance-brightgreen.svg)
@@ -28,6 +37,9 @@ License-File: LICENSE
28
37
 
29
38
  An open-source Python library for identifying bottlenecks in code. It includes function profiling, data exports, logging, and line-by-line profiling for more granular control.
30
39
 
40
+ ## Changelog (v.1.0.2):
41
+ - Added support for 2 new export formats: `xml` and `md` in both function profiling, and line-by-line profiling.
42
+
31
43
  ## Installation
32
44
 
33
45
  You can install FuncProfiler using pip:
@@ -54,7 +66,7 @@ Please ensure that you have one of these Python versions installed. FuncProfiler
54
66
  - **Function Profiling**: Monitor a function's memory usage and execution time to identify performance issues.
55
67
  - **Line-by-Line Profiling**: Return execution time and memory usage for each line of any given function.
56
68
  - **Shared Logging**: Log outputs of functions triggered by the line-by-line and function profilers, storing results in a `.txt` file.
57
- - **File Exports**: Export profiling data from functions in `csv`, `json`, or `html` formats.
69
+ - **File Exports**: Export profiling data from functions in `csv`, `json`, `html`, `xml` and `md` formats, for both line-by-line profiling and function profiling.
58
70
  > [!NOTE]
59
71
  > View more export types in the [official documentation](https://infinitode-docs.gitbook.io/documentation/package-documentation/funcprofiler-package-documentation).
60
72
 
@@ -5,13 +5,13 @@ with open("README.md", "r", encoding="utf-8") as fh:
5
5
 
6
6
  setup(
7
7
  name='funcprofiler',
8
- version='1.0.1',
8
+ version='1.0.2',
9
9
  author='Infinitode Pty Ltd',
10
10
  author_email='infinitode.ltd@gmail.com',
11
11
  description='An open-source Python library for finding bottlenecks in code. Includes function profiling, data exports, logging, and even line-by-line profiling, for more control.',
12
12
  long_description=long_description,
13
13
  long_description_content_type='text/markdown',
14
- url='https://github.com/infinitode/valx',
14
+ url='https://github.com/infinitode/funcprofiler',
15
15
  packages=find_packages(),
16
16
  classifiers=[
17
17
  'Development Status :: 5 - Production/Stable',
@@ -24,6 +24,7 @@ setup(
24
24
  'Programming Language :: Python :: 3.10',
25
25
  'Programming Language :: Python :: 3.11',
26
26
  'Programming Language :: Python :: 3.12',
27
+ 'Programming Language :: Python :: 3.13',
27
28
  ],
28
29
  python_requires='>=3.6',
29
30
  )
File without changes
File without changes