Skip to content
This repository was archived by the owner on Apr 30, 2021. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions pythonfuzz/fuzzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import hashlib
import logging
import coverage
import functools
import multiprocessing as mp

from pythonfuzz import corpus
Expand All @@ -14,6 +15,28 @@

SAMPLING_WINDOW = 5 # IN SECONDS

if coverage.version.version_info <= (5, ):
# Since we're using an old version of coverage.py,
# we're monkey patching it a bit to improve the performances.

# Using memoization here gives +50% in performances, since this
# function triggers a lot of syscalls.
# See the benchmarks here:
# - https://github.com/fuzzitdev/pythonfuzz/issues/9
@functools.lru_cache(None)
def abs_file(path):
"""Return the absolute normalized form of `path`."""
try:
path = os.path.realpath(path)
except UnicodeError:
pass
path = os.path.abspath(path)
path = coverage.files.actual_path(path)
path = coverage.files.unicode_filename(path)
return path

coverage.files.abs_file = abs_file_cache


def worker(target, child_conn):
cov = coverage.Coverage(branch=True, cover_pylib=True)
Expand Down