File: nipguidese35.html

package info (click to toggle)
nip2 8.9.1-1
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 23,352 kB
  • sloc: ansic: 64,077; sh: 4,681; yacc: 1,133; makefile: 927; lex: 386; xml: 40; perl: 17
file content (73 lines) | stat: -rw-r--r-- 3,643 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  
  "http://www.w3.org/TR/html4/loose.dtd">  
<html > 
<head><title>Optimisation</title> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
<meta name="generator" content="TeX4ht (http://www.tug.org/tex4ht/)"> 
<meta name="originator" content="TeX4ht (http://www.tug.org/tex4ht/)"> 
<!-- 3,html --> 
<meta name="src" content="nipguide.tex"> 
<link rel="stylesheet" type="text/css" href="nipguide.css"> 
</head><body 
>
  <!--l. 1527--><div class="crosslinks"><p class="noindent">[<a 
href="nipguideap1.html" >next</a>] [<a 
href="nipguidese34.html" >prev</a>] [<a 
href="nipguidese34.html#tailnipguidese34.html" >prev-tail</a>] [<a 
href="nipguidese34.html#tailnipguidese35.html">tail</a>] [<a 
href="nipguidech6.html#nipguidese36.html" >up</a>] </p></div>
  <h3 class="sectionHead"><span class="titlemark">6.14    </span> <a 
 id="x46-870006.14"></a>Optimisation</h3>
<!--l. 1528--><p class="noindent" ><a name="nip_label_sec:optimise"></a>
<!--l. 1530--><p class="indent" >  <span 
class="phvr7t-x-x-80">nip2 </span>performs three useful optimisations on expressions.
First, it finds and removes common sub-expressions in
functions. So for example:
                                                 <div class="verbatim" id="verbatim-89">
  if&#x00A0;a&#x00A0;+&#x00A0;b&#x00A0;&#x003C;&#x00A0;12&#x00A0;then&#x00A0;a&#x00A0;+&#x00A0;b&#x00A0;else&#x00A0;b 
</div>
<!--l. 1535--><p class="nopar" >
<!--l. 1537--><p class="noindent" >will only evaluate <span 
class="phvr7t-x-x-80">a + b </span>once. This can save a lot of time if <span 
class="phvr7t-x-x-80">a</span>
or <span 
class="phvr7t-x-x-80">b </span>is a large image.
<!--l. 1541--><p class="indent" >    Second, <span 
class="phvr7t-x-x-80">nip2 </span>detects arithmetic operations on <span 
class="phvr7t-x-x-80">unsigned</span>
<span 
class="phvr7t-x-x-80">char </span>images, and replaces them with look-up tables. For
example:
                                                                                       

                                                                                       
  <div class="verbatim" id="verbatim-90">
a&#x00A0;=&#x00A0;vips_image&#x00A0;"campin.v"
&#x00A0;<br />b&#x00A0;=&#x00A0;a&#x00A0;&#x22C6;&#x00A0;(a&#x00A0;-&#x00A0;1)&#x00A0;&#x22C6;&#x22C6;&#x00A0;0.5
</div>
<!--l. 1547--><p class="nopar" >
<!--l. 1549--><p class="noindent" >Provided <span 
class="phvr7t-x-x-80">campin.v </span>is an 8 bit image image, this expression
will evaluate with a single call to <span 
class="phvr7t-x-x-80">im</span><span 
class="phvr7t-x-x-80">_maplut()</span>.
<!--l. 1553--><p class="indent" >  Finally, <span 
class="phvr7t-x-x-80">nip2 </span>has a VIPS operation cache. It memorises the
arguments to the last few hundred calls to VIPS, and the
result each call gave. Before calling VIPS again, it
checks to see if there is a previous call with the same
arguments and if there is, uses the result it obtained last
time.
                                           
                                                                                       

                                                                                       
  <!--l. 1558--><div class="crosslinks"><p class="noindent">[<a 
href="nipguideap1.html" >next</a>] [<a 
href="nipguidese34.html" >prev</a>] [<a 
href="nipguidese34.html#tailnipguidese34.html" >prev-tail</a>] [<a 
href="nipguidese35.html" >front</a>] [<a 
href="nipguidech6.html#nipguidese36.html" >up</a>] </p></div>
<!--l. 1558--><p class="indent" >  <a 
 id="tailnipguidese35.html"></a>  
</body></html>