Skip to content

Commit

Permalink
Profiling for sub-process
Browse files Browse the repository at this point in the history
  • Loading branch information
andresriancho committed Jan 27, 2015
1 parent e6914ce commit 66155a1
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 24 deletions.
32 changes: 20 additions & 12 deletions w3af/core/controllers/profiling/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,28 @@


def start_profiling(w3af_core):
start_cpu_profiling(w3af_core)
start_memory_profiling(w3af_core)
start_core_profiling(w3af_core)
start_thread_stack_dump(w3af_core)
start_process_dump(w3af_core)
start_psutil_dump(w3af_core)
start_tracemalloc_dump(w3af_core)
start_profiling_no_core()


def start_profiling_no_core():
start_cpu_profiling()
start_memory_profiling()
start_thread_stack_dump()
start_process_dump()
start_psutil_dump()
start_tracemalloc_dump()


def stop_profiling(w3af_core):
stop_cpu_profiling(w3af_core)
stop_memory_profiling(w3af_core)
stop_core_profiling(w3af_core)
stop_thread_stack_dump(w3af_core)
stop_process_dump(w3af_core)
stop_psutil_dump(w3af_core)
stop_tracemalloc_dump(w3af_core)
stop_profiling_no_core()


def stop_profiling_no_core():
stop_cpu_profiling()
stop_memory_profiling()
stop_thread_stack_dump()
stop_process_dump()
stop_psutil_dump()
stop_tracemalloc_dump()
4 changes: 2 additions & 2 deletions w3af/core/controllers/profiling/cpu_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def inner(w3af_core):


@should_profile_cpu
def start_cpu_profiling(w3af_core):
def start_cpu_profiling():
"""
If the environment variable W3AF_PROFILING is set to 1, then we start
the CPU and memory profiling.
Expand All @@ -60,7 +60,7 @@ def dump_data():


@should_profile_cpu
def stop_cpu_profiling(w3af_core):
def stop_cpu_profiling():
"""
Save profiling information (if available)
"""
Expand Down
4 changes: 2 additions & 2 deletions w3af/core/controllers/profiling/memory_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def inner(w3af_core):


@should_profile_memory
def start_memory_profiling(w3af_core):
def start_memory_profiling():
"""
If the environment variable W3AF_PROFILING is set to 1, then we start
the CPU and memory profiling.
Expand All @@ -59,7 +59,7 @@ def dump_objects():


@should_profile_memory
def stop_memory_profiling(w3af_core):
def stop_memory_profiling():
"""
We cancel the save thread and dump objects for the last time.
"""
Expand Down
4 changes: 2 additions & 2 deletions w3af/core/controllers/profiling/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def inner(w3af_core):


@should_dump_processes
def start_process_dump(w3af_core):
def start_process_dump():
"""
If the environment variable W3AF_PROCESSES is set to 1, then we start
the thread that will dump the sub processes created by this main thread.
Expand Down Expand Up @@ -96,7 +96,7 @@ def dump_processes():


@should_dump_processes
def stop_process_dump(w3af_core):
def stop_process_dump():
"""
Save profiling information (if available)
"""
Expand Down
4 changes: 2 additions & 2 deletions w3af/core/controllers/profiling/psutil_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def inner(w3af_core):


@should_dump_psutil
def start_psutil_dump(w3af_core):
def start_psutil_dump():
"""
If the environment variable W3AF_PSUTILS is set to 1, then we start
the thread that will dump the operating system data which can be retrieved
Expand Down Expand Up @@ -133,7 +133,7 @@ def ps_mem_to_json(sorted_cmds, shareds, count, total):


@should_dump_psutil
def stop_psutil_dump(w3af_core):
def stop_psutil_dump():
"""
Save profiling information (if available)
"""
Expand Down
4 changes: 2 additions & 2 deletions w3af/core/controllers/profiling/pytracemalloc.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def inner(w3af_core):


@should_dump_tracemalloc
def start_tracemalloc_dump(w3af_core):
def start_tracemalloc_dump():
"""
If the environment variable W3AF_PYTRACEMALLOC is set to 1, then we start
the thread that will dump the memory usage data which can be retrieved
Expand Down Expand Up @@ -91,7 +91,7 @@ def dump_tracemalloc():


@should_dump_tracemalloc
def stop_tracemalloc_dump(w3af_core):
def stop_tracemalloc_dump():
"""
Save profiling information (if available)
"""
Expand Down
4 changes: 2 additions & 2 deletions w3af/core/controllers/profiling/thread_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def inner(w3af_core):


@should_dump_thread_stack
def start_thread_stack_dump(w3af_core):
def start_thread_stack_dump():
"""
If the environment variable W3AF_THREAD_ACTIVITY is set to 1, then we start
the thread that will dump the current line being executed of every thread
Expand Down Expand Up @@ -71,7 +71,7 @@ def dump_thread_stack():


@should_dump_thread_stack
def stop_thread_stack_dump(w3af_core):
def stop_thread_stack_dump():
"""
Save profiling information (if available)
"""
Expand Down
2 changes: 2 additions & 0 deletions w3af/core/data/parsers/parser_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import w3af.core.controllers.output_manager as om

from w3af.core.controllers.profiling import start_profiling_no_core
from w3af.core.controllers.threads.process_pool import ProcessPool
from w3af.core.controllers.output_manager import log_sink_factory
from w3af.core.data.parsers.document_parser import DocumentParser
Expand Down Expand Up @@ -285,6 +286,7 @@ def init_worker(log_queue):
"""
signal.signal(signal.SIGINT, signal.SIG_IGN)
log_sink_factory(log_queue)
start_profiling_no_core()


manager = multiprocessing.Manager()
Expand Down

0 comments on commit 66155a1

Please sign in to comment.