Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert tools/vipsprofile to Python 3+2 #1262

Merged
merged 1 commit into from Mar 20, 2019
Merged

Convert tools/vipsprofile to Python 3+2 #1262

merged 1 commit into from Mar 20, 2019

Conversation

hroncok
Copy link
Contributor

@hroncok hroncok commented Mar 20, 2019

I don't know how to test this (I don't know or use libvips), so please give it a try.
Unless there is a typo, I'm pretty confident this cannot break anything, however I don't know yet if this the full change needed.

@jcupitt
Copy link
Member

jcupitt commented Mar 20, 2019

Hello, thanks for this!

I tried it out and there are two small problems still.

  1. The ReadFile class uses the py2 __nonzero__ overload to detect end of file. It needs to add __bool__ = __nonzero__ (or the reverse, I guess?) for py3.
  2. There are the usual Python int/float division mixups. Probably from __future__ import division and move everything to py3 style is best.

Would you like to make these changes? I can do it if you're busy.

You can test the script like this:

$ vips gaussblur wtc.v x.tif 5 --vips-profile
recording profile in vips-profile.txt
$ vipsprofile 
reading from vips-profile.txt
loaded 28806 events
total time = 1.575308
name		alive	wait%	work%	unkn%	memory	peakm
    worker 20	   1.3	 0.0477	89.2	10.8	 0.47	 0.47	
    worker 21	   1.3	 0.0328	89.5	10.4	 0.47	 0.47	
    worker 22	   1.3	 0.062	87.9	12.1	 0.47	 0.47	
    worker 23	   1.3	 0.993	88.8	10.2	 0.47	 0.47	
    worker 24	   1.3	 0.261	89	10.8	 0.47	 0.47	
    worker 25	   1.3	 0.733	88	11.3	 0.47	 0.47	
    worker 26	   1.3	 0.267	88.1	11.6	 7.33	 7.33	
    worker 27	   1.3	 0.0407	89.1	10.9	 0.47	 0.47	
   wbuffer 28	   1.3	 92.1	7.85	0.00633	 0	 0	
   wbuffer 29	   1.3	 92.6	7.38	0.00687	 0	 0	
      main 30	   1.6	 81.9	0	18.1	 -8.14	 10.3	
peak memory = 20.9 MB
leak! final memory = 2.49 MB
writing to vips-profile.svg

I'm not sure why it's claiming a leak, I should check.

@hroncok
Copy link
Contributor Author

hroncok commented Mar 20, 2019

I'll get back to that later today. Thanks for fast feedback.

@hroncok
Copy link
Contributor Author

hroncok commented Mar 20, 2019

Do you have some wtc.v to test with?

Anyway, I tried to guess hard what should use floor division, hopefully I got it right.

@jcupitt
Copy link
Member

jcupitt commented Mar 20, 2019

You can use any image. That was a 10k x 10k RGB (you need to give it something big to get a nice graph), but anything would work.

@hroncok
Copy link
Contributor Author

hroncok commented Mar 20, 2019

I've used benchmark/sample2.v and this is what I got:

vips-profile svg

@jcupitt
Copy link
Member

jcupitt commented Mar 20, 2019

That looks great!

@jcupitt jcupitt merged commit 71a9099 into libvips:master Mar 20, 2019
@jcupitt
Copy link
Member

jcupitt commented Mar 20, 2019

I read your patch and I agree with everything. Nice job, and thank you very much for doing this work!

@hroncok hroncok deleted the vipsprofile_py3 branch March 20, 2019 16:11
@hroncok
Copy link
Contributor Author

hroncok commented Mar 20, 2019

Thanks.

KoviRobi added a commit to KoviRobi/nixpkgs that referenced this pull request Aug 22, 2021
The new optional dependencies increase closure size from 388.92 MiB to
414.0 MiB, a negligible change. I didn't think there was any reason to
add `withLibjpeg ? true` flags (or `enableLibjpeg`).

The optional dependencies are sorted in the order of
https://github.com/libvips/libvips/blob/master/README.md
and I have used `nix log` on the build to check they are all picked up
in configure.

The python3 support was in for ages
(libvips/libvips#202), the remaining python3
support in tools/vipsprofile landed in
libvips/libvips#1262 so I upgraded it to
python3. I wasn't sure if I should use a specific version, or just leave
it as python3.

I have tested vipsprofile with
```
./vips-pycairo-bin/bin/vips gaussblur ~/2021-04-30-092143_3286x1080_scrot.png x.tif 5 --vips-profile
./vips-pycairo-bin/bin/vipsprofile
```
where ~/2021-04-30-092143_3286x1080_scrot.png is just a random image
(screenshot) I had lying around. It seems to have generated an SVG file,
I don't know how to interpret it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants