count pages in pdf without opening c# : Delete pages from pdf acrobat reader application SDK tool html wpf windows online antocuni-thesis8-part324

Chapter 8
Benchmarks
8.1 Applying the JIT to the Python Interpreter
Chapters6and7explainhowthePyPyJITgeneratorworks.Inparticular,inSection6.2
wehaveshownthatitispossibletogenerateaJITcompilerfromeveryinterpreterwritten
inRPython. TomeasuretheperformanceofthegeneratedJIT,andinparticularofthe
JITwiththeCLIbackend,weapplytheJITgeneratortothePythonStandardInterpreter
ofPyPy(seeSection3.2).
AsexplainedbySection6.3.3,itisnecessarytoapplysomehints toguidetheJITgen-
erationprocess. Thetwomostimportanthintsare
jit_merge_point
whichindicatesthe
startofthemaininterpreterloop,and
can_enter_jit
whichindicatesalltheplaceswhere
user loopshave tobe checked. Figure e 8.1shows a simpliedversionof the maininter-
preterloopofthePythonInterpreter: notethat
can_enter_jit
iscalledonlyattheend
of
JUMP_ABSOLUTE
,whichistheonlyPythonopcodethatcansettheinstructionpointer
toanearliervalue,i.e.theonlyonethatcanpossiblyleadtoauserloop.
Apartfromthesetwofundamentalhints,thePythonInterpretercontainsabout30more
hintstoguidetheJITtoproducebettercode. Thesehintshavenotbeenexplainedinthis
thesisbut,e.g.,marksomeclassesas\immutable",tolettheJITknowthattheirinstances
neverchangestheirstateaftertheyhavebeencreated.Theamountofneededhintsisquite
modest comparedto the about 100K LOCwhichcomposethe PythonInterpreter: this
supportstheclaimstatedinSection6.3.3thattheextraworkneededtoenabletheJIT
foralargeinterpreterisnegligible.
Then,itispossibletoinvokethetranslatorandenabletheJITgeneratortogetanal
executablethatcontainsboththePythonInterpreterandthecorrespondingJITcompiler.
Inthe following,wewillreferto
pypy-cli
toindicatethePythoninterpreter translated
72
Delete pages from pdf acrobat reader - application SDK tool:C# PDF Page Extract Library: copy, paste, cut PDF pages in C#.net, ASP.NET, MVC, Ajax, WinForms, WPF
Easy to Use C# Code to Extract PDF Pages, Copy Pages from One PDF File and Paste into Others
www.rasteredge.com
Delete pages from pdf acrobat reader - application SDK tool:VB.NET PDF Page Extract Library: copy, paste, cut PDF pages in vb.net, ASP.NET, MVC, Ajax, WinForms, WPF
Detailed VB.NET Guide for Extracting Pages from Microsoft PDF Doc
www.rasteredge.com
pypyjitdriver = JitDriver(greens = [’next_instr’’pycode’],
reds = [’self’’ec’])
class PyFrame(Frame):
def dispatch(self, pycode, next_instr, ec):
try:
while True:
pypyjitdriver.jit_merge_point()
co_code = pycode.co_code
next_instr = self.handle_bytecode(co_code,
next_instr, ec)
except ExitFrame:
return self.popvalue()
def JUMP_ABSOLUTE(self, jumpto, _, ec=None):
self.last_instr = jumpto
ec.bytecode_trace(self)
jumpto = = self.last_instr
pypyjitdriver.can_enter_jit()
return jumpto
...
Figure8.1: Maininterpreterloopofthe e PyPyPythonInterpreter
withtheCLItranslationbackendandtheCLIJITbackend.
8.2 Making the interpreter JIT friendly
Inordertogetgoodperformanceitisnecessarytohaveaverygoodtraceoptimizer(see
section6.5). Inanidealworld,theoptimizerwouldbesmartenoughtooptimizeallthe
possibleprogrammingpatternsthatarefoundintheinterpreter. However,therealityis
that at the moment not allprogramming patterns areoptimized equally well, , with the
resultthatsomecodefragmentsareoptimizedbytheJITmorethanothers.
Thenetresultisthat
pypy-cli
canoccasionallyencounterauserprogramthatrequiresthe
executionofthoseinterpreterfragmentswhichcannotbereasonablyoptimizedbytheJIT,
thusgeneratingnonoptimalandsometimeseveninecientcode. Tosolvetheseproblems
therearetwopossiblesolutions: eitherenhancingtheoptimizer,orrewritingtheinvolved
partsoftheinterpretertoallowtheJITtoperformsomeusefuloptimization.
AtthemomentofwritingtheareknownfragmentsofthePythonInterpreterwherethe
73
application SDK tool:.NET PDF Document Viewing, Annotation, Conversion & Processing
Redact text content, images, whole pages from PDF file. Annotate & Comment. Edit, update, delete PDF annotations from PDF file. Print.
www.rasteredge.com
application SDK tool:C# PDF Converter Library SDK to convert PDF to other file formats
manipulate & convert standard PDF documents in .NET class applications independently, without using other external third-party dependencies like Adobe Acrobat.
www.rasteredge.com
JITperformsbadly,asSection8.4highlightsverywell.Thesefragmentsinclude:
 Old-styleclasses
1
:thePyPyteamhasalwaysputmoreeortonoptimizingnew-style
classesthanold-style,withtheresultthattheformer aredramaticallyfasterboth
duringnormalinterpretationandwiththeJIT.
 Stringmanipulation: someofthealgorithms s forstring processingimplementedin
PyPyareinferiortotheonesusedby CPythonorIronPython,thus evenwiththe
helpoftheJITtherearecasesinwhichtheyperformbadly.
 Regularexpressions:intheory,itshouldbepossibletoconsidertheregularexpression
engineasanotherinterpretertobeJITtedseparatelyfromthemainone,thusgetting
veryoptimizedmachinecodeforeachdierentregularexpression. However,atthe
moment this is not possiblefortechnicalreasons,and thus the regular expression
engineisnotconsideredbytheJIT.
None of the above e items represents s a fundamental l issue e that cannot be solved d by y our
approach,buthaveneverbeentackledduetotimeconstraints. Howeveratthemoment
ofwritingthePyPyteamisactivelyworkingonthem.
8.3 Methodology
Tomeasuretheperformanceof
pypy-cli
weselectedtwosetofbenchmarks:therstisa
collectionof82microbenchmarkswhichtestvariousaspectsofthePythonlanguage,while
thesecondis acollectionof13middle-sizedprogramsthatdovariouskindof\reallife"
computations.
Theperformanceof
pypy-cli
ismeasuredagainstIronPython.IronPythonhasanumberof
command-lineoptionstoenableordisablesomePythonfeaturesthatarehardtoimplement
eciently. Since
pypy-cli
fullysupportsallofthesefeatures,wedecidedtoenablethem
alsoinIronPythontomakeafaircomparison.Inparticular,welaunchedIronPythonwith
the options
-X:FullFrames
whichenables supportfor
sys._getframe
,and
-X:Tracing
,
whichenables support for
sys.settrace
(seeSection2.1.6formore details). Notethat
thespiritbehindthechoicesofthePyPyandIronPythonteamsisdierent:inIronPython,
itisconsideredreasonabletodisablesuchrarelyusedfeaturesbydefaultbecausetheylead
to less ecient code, while the goalof PyPy is s to implement the fullsemantics ofthe
languagewithoutcompromises,andlettheJITtooptimizethecodefragmentswheresuch
1
old-styleclassesimplementtheclassicalobjectmodelofPython. Since e version2.2, theyhavebeen
deprecatedandputsidebysidetonew-style classes,whichareslightlyincompatible.
74
application SDK tool:C# powerpoint - PowerPoint Conversion & Rendering in C#.NET
documents in .NET class applications independently, without using other external third-party dependencies like Adobe Acrobat. PowerPoint to PDF Conversion.
www.rasteredge.com
application SDK tool:C# Word - Word Conversion in C#.NET
Word documents in .NET class applications independently, without using other external third-party dependencies like Adobe Acrobat. Word to PDF Conversion.
www.rasteredge.com
dynamicfeaturesarenotused,whilestillproducingcorrectresultswhentheyareactually
used.
Followingthemethodologyproposedby[GBE07],eachmicrobenchmarkandmiddle-sized
benchmarkhasbeenrunfor10and30timesinarow,respectively.Sinceweareinterested
in steady-state performance the rst run of each benchmark k has been n discarded, as it
supposedlyincludesthetimespentbyallthelayersofJITcompilation.Thenalnumbers
werereached by y computing the average of allotherruns, , the e condenceintervals were
computedusinga95%condencelevel.
Alltests have beenperformed onanotherwise idle machine with anIntel Core i7 920
CPUrunningat2.67GHzwith4GBRAM.AllbenchmarkswererunbothunderLinux
usingMono,theopensourceimplementationoftheCLI,andunder MicrosoftWindows
XPusingthe CLR,whichisthe originalimplementationof the CLIby Microsoft. The
followingisalistoftheversionsofthesoftwareused:
 Ubuntu9.10KarmicKoala,withLinux2.6.31
 Mono2.4.2.3
 IronPython2.6.10920.0
 MicrosoftWindowsXPSP2
 MicrosoftCLR2.0.50727.1433
2
8.4 Microbenchmarks
Figure8.2showstheresultsofthemicrobenchmarks:foreachbenchmark,thebarindicates
thespeedup(orslowdown)factorof
pypy-cli
comparedtoIronPython.
OnMono
pypy-cli
performsverywellonmostbenchmarkswithspeedupsupto215times
fasterandonly20onessloweddown,assummarizedbyFigure8.3.
OnCLR
pypy-cli
performsabit worse,buttheresultsarestillverysatisfactory,with
speedupsupto155timesfasterandonly21benchmarkssloweddown. However,insome
casestheslowdownisveryconsiderable,upto78timesslower.Figure8.4summarizesthe
results.
2
Atthemomentofwriting,themostrecentversionofthe.NETFrameworkis3.5.Howeverthevirtual
machineatthecoreoftheFrameworkhasnotbeenupdatedsince.NET2.0,hencetheversionoftheCLR.
75
application SDK tool:C# Windows Viewer - Image and Document Conversion & Rendering in
standard image and document in .NET class applications independently, without using other external third-party dependencies like Adobe Acrobat. Convert to PDF.
www.rasteredge.com
application SDK tool:VB.NET PDF: How to Create Watermark on PDF Document within
Watermark Creator, users need no external application plugin, like Adobe Acrobat. VB example code to create graphics watermark on multiple PDF pages within the
www.rasteredge.com
-100
-50
0
50
100
150
200
call_1
call_2
call_3
call_4
call_default_1
call_default_2
call_fabs
call_function
call_function_with_arguments_in_cellvars
call_function_without_arguments_in_cellvars
call_keyword_1
call_keyword_2
call_keyword_3
call_method_of_new_style_class
call_method_of_old_style_class
call_nested_function
call_nested_function_many_args
call_nested_function_other_count
call_sin
dict_class_dict_getmethod
dict_class_dict_getmethod_old_style
dict_creation_mode1
dict_creation_mode2
dict_creation_mode3
dict_formatting
dict_getitem
dict_instance_getattr_instance_dict
dict_instance_getattr_instance_dict_old_style
dict_instance_setattr_instance_dict
dict_instance_setattr_instance_dict_old_style
dict_instance_setnewattr_instance_dict
dict_instance_setnewattr_instance_dict_old_style
dict_raw_range
dict_setitem1
dict_setitem2
exc_except_multiple_builtin_exception
exc_except_multiple_user_exception
exc_except_specific_builtin_exception
exc_except_specific_user_exception
exc_instantiate_builtin_exception
exc_instantiate_user_exception
exc_raise_builtin_exception
exc_raise_user_exception
exc_reraise
exc_try_except
exc_try_except_else
exc_try_except_finally
list_append
list_extend
list_getitem
list_setitem
list_slice
loop
loop_count_2
loop_count_in_attr
loop_count_in_dict
loop_count_in_global
loop_count_in_global2
loop_count_in_slot
loop_count_increment_in_global
loop_count_with_True
loop_count_with_global_increment
loop_other_count
loop_unrolled
new_style___new__
new_style_create
new_style_isinstance1
new_style_isinstance2
new_style_isinstance3
old_style_create
old_style_isinstance1
old_style_isinstance3
str_find_pattern1
str_find_pattern16
str_find_pattern2
str_find_pattern4
str_find_pattern8
str_find_pattern_1000
str_format_long
str_number_formatting
str_repr_formatting
str_simple_formatting
Times faster
Mono
CLR
Figure8.2: Speedupofpypy-clivsIronPython(microbench)
76
application SDK tool:C# Excel - Excel Conversion & Rendering in C#.NET
Excel documents in .NET class applications independently, without using other external third-party dependencies like Adobe Acrobat. Excel to PDF Conversion.
www.rasteredge.com
application SDK tool:VB.NET PowerPoint: VB Code to Draw and Create Annotation on PPT
of compensation for limitations (other documents are compatible, including PDF, TIFF, MS on slide with no more plug-ins needed like Acrobat or Adobe reader.
www.rasteredge.com
Speedupfactor
No.
100 to 250 faster
6
25 to 100
16
10 to
25
17
2 to
10
15
1 to
2
8
1 to
2 slower
4
2 to
10
14
10 to
25
2
25 to 100
0
Figure8.3: MicrobenchmarksonMono
Speedupfactor
No.
100 to 250 faster
4
25 to 100
6
10 to
25
15
2 to
10
27
1 to
2
9
1 to
2 slower
6
2 to
10
11
10 to
25
2
25 to 100
2
Figure 8.4: : MicrobenchmarksonCLR
Itisinterestingtonotethatmostofthebadresultsarerelatedtotheexecutionofthose
fragmentswheretheJITisknowntoperformbadly,asdescribedinSection8.2:inpartic-
ular,old-styleclassesandoperationsthatinvolvestrings. Moreover,italsoemergesthat
allthemicrobenchmarksthatcreateamassiveamountofnewobjectsareusuallyslower.
Anothernoteworthyobservationisthatgenerally
pypy-cli
hasagreaterspeedupfactor
overIronPythononMonothanonCLR.
8.5 Middle-sized benchmarks
Figure8.5containsashortdescriptionsofthe13middle-sizedbenchmarksthathavebeen
executedtofurtherevaluatetheperformanceof
pypy-cli
versusIronPython.
Figure8.6showsthetimetakenby
pypy-cli
andIronPythontocompleteeachbenchmark.
TheresultsonMonoshowclearlythatforthemajorpartofthebenchmarks,
pypy-cli
is
fasterthanIronPython. Itisinterestingtoanalyzethebenchmarksthatareslower:
build-tree
createsamassiveamountofnewobjects,showingthesamebehaviour
alreadynotedforthemicrobenchmarks.Thisisanunexpectedresultthathavenot
beeninvestigatedfurtherduetotimeconstraints,butwillbeanalyzedasapartof
thefuturework.
fannkuch
doesnot evencomplete. This s is becausetheJITcreatestwomutualre-
cursiveloops(seeSection7.5.1)thatcallseachotherwithatail-call. However,due
toabugintheimplementationoftailcallsonMono(seeSection4.4)theprogram
exhauststhestackspaceandterminatesabnormally.
77
Name
Description
build-tree
Createandtraverseofahugebinarytree(1millionofelements)
chaos
Generateanimagecontainingachaosgame-likefractal
f1
Twonestedloopsdoingintensivecomputationwithintegers
fannkuch
Theclassicalfannkuchbenchmark[AR]
float
Exerciseboth oatingpointandobjectorientedoperationsbyencap-
sulating(x;y)pairsinaPointclass
html
GenerateahugeHTMLtable
k-nucleotide
AnalyzenucleotidesequencesexpressedinFASTAformat [fBI10]
linked-list
Createahugelinkedlist
oobench
Measuretheperformanceofmethodinvocationonobjects
pystone
ThestandardPythonbenchmark,derivedfromtheclassicalDhrystone
[Wik10a]
pystone-new
Thesameaspystone,butusingnew-styleclassesinsteadofold-style
ones
richards
The classicalRichards benchmarks,originally y writteninBCPLand
rewritteninPython
spectral-norm Computetheeigenvalueusingthepowermethod
Figure 8.5: : Descriptionofthebenchmarks
html
involvesalotofoperationsonstrings,thus
pypy-cli
wasexpectedtobeslower.
Howeveritisinterestingtoseethatthedierenceisminimal:thisisprobablydueto
thefactthatalltheotheroperations(likemethodinvocationandattributeaccess)
arespeededupby
pypy-cli
,balancingtheslowdowncausedbythestringoperations.
k-nucleotide
isonlyaboutoperationsonstrings,thustheslowdownisinlinewith
whatobservedbythemicrobenchmarks.
pystone
isslowerbecauseitusesold-styleclasses.
pystone-new
,whichusesnew-style
classes,ismuchfasteron
pypy-cli
.
OnCLRtheresultsarelesssatisfactory:7outof13benchmarksarefaster,buttheother
6areslower,sometimesevenbyalargefactor. Itisinterestingtonotethatonthetwo
benchmarksthatinvolvealotofstringmanipulation(
html
and
k-nucleotide
),
pypy-cli
behavesbetteronCLRthanonMonoandoutperformsIronPython.IntheCLRhistogram,
thedatafor
chaos
havebeenomittedfor
pypy-cli
becauseitproducesincorrectresults:
thisisprobablyduetoabugintheCLRitself,asonMonoitworkscorrectly.
ThehistograminFigure8.7summarizestheresultsbyshowingthespeedup(orslowdown)
factorof
pypy-cli
overIronPython.
f1
and
oobench
arethebenchmarkswiththelargest
78
0
2
4
6
8
10
build-tree
chaos
f1
fannkuch
float
html
k-nucleotide
linked-list
oobench
pystone
pystone-new
richards
spectral-norm
Time (s)
Benchmarks on Mono
pypy-cli
IronPython
0
2
4
6
8
10
build-tree
chaos
f1
fannkuch
float
html
k-nucleotide
linked-list
oobench
pystone
pystone-new
richards
spectral-norm
Time (s)
Benchmarks on CLR
pypy-cli
IronPython
Figure8.6: TimetakentocompletethebenchmarksonMonoandCLR(thelowerthebetter)
79
speedupfactor,uptoabout31and37timesfasteronMono,and12and13timesfasteron
CLR.
float
,
richards
and
spectral-norm
arealsoconsistentlyspeededupbutbysmaller
factor. Some benchmarks s (
html
,
k-nucleotide
,
linked-list
,
pystone-new
) exhibit t a
controversialbehavior,astheyarespeededupbyanimplementationandsloweddownby
theother,orviceversa.Finally,
build-tree
and
pystone
areconsistentlysloweddownby
pypy-cli
.
-5
0
5
10
15
20
25
30
35
40
build-tree
chaos
f1
fannkuch
float
html
k-nucleotide
linked-list
oobench
pystone
pystone-new
richards
spectral-norm
Times faster
mono
CLR
Figure 8.7: Speedup p factorof
pypy-cli
overIronPython onMono and CLR (the e higherthe
betterfor
pypy-cli
)
8.5.1 DierencesbetweenMonoandCLR
WhyonMono
pypy-cli
gets muchbetter resultscomparedtoIronPython? Figure8.8
comparesside-by-sidetheperformanceofthetwoplatformswhenrunningeither
pypy-cli
orIronPython:remindthatallthebenchmarkswererunonthesamemachine(although
on dierent operating systems), so o the results are directly comparable. With h the sole
80
exceptionof
build-tree
,IronPythonisconsistentlyfasteronCLRthanonMono.Thisis
probablyduetothefactthatIronPythonhasbeenexplicitlyoptimizedfortheCLRand
viceversa,sincebothprojectshavebeendevelopedbyMicrosoft.
Ontheotherhand,forsomebenchmarks
pypy-cli
behavesbetteronMonothanonCLR,
whileforothersistheopposite.Probably,thisisduetothefactthatthebytecodegenerated
bythehigherlevelJITcompiler of
pypy-cli
isverydierent fromthetypicalbytecode
generatedbyothercompilersforCLI(e.g.byC#compilers),thusisnotalwaysproperly
optimizedbythelowerlevelJITcompiler. Thefactthat
chaos
doesnotworkcorrectly
onCLRsupportsthistheory,asthecodeproducedby
pypy-cli
triggersabugthatithas
probablybeenunobservedforyears.
81
Documents you may be interested
Documents you may be interested