When I try to profile my python code in this manner I get an output where it shows the time taken by the python lines only and not the c++ lines. I am using '%prun -s'command to help profile these lines. The code is written in Jupyter Notebook.
from Cython.Compiler.Options import get_directive_defaults
directive_defaults = get_directive_defaults()
directive_defaults['linetrace'] = True
directive_defaults['binding'] = True
%load_ext cython
%%cython
# cython: profile=True
from pygpb import libgpb
import numpy as np
from skimage import io, color
import matplotlib.pyplot as plt
from skimage import io
import os
import sys
from timeit import default_timer as timer
def main(path):
n_ori, Kmean_num, sigma_sm, sigma_lg = 8, 64, 2.0, np.sqrt(2)*2.0
# run it
gpb = libgpb.Gpb()
img = io.imread(path)
if(img.strides[1] > 3):
img = (255 * color.rgba2rgb(img)).astype(np.uint8)
gpb.test_np_mat(img, img)
# get texton
texton = gpb.texton(img, n_ori,
Kmean_num,
sigma_sm, sigma_lg)
start = timer();
gpb_res, ucm_res = gpb.run(img)
end = timer();
print("Time taken by demo is : " ,end-start, "seconds") #time in seconds:
[picture of the output][1]
[1]: https://i.stack.imgur.com/zlddP.jpg