c# generating barcode Delphi Example of Code That s Better Suited to Assembler in Visual C#.NET

Creator EAN / UCC - 13 in Visual C#.NET Delphi Example of Code That s Better Suited to Assembler

Delphi Example of Code That s Better Suited to Assembler
Encoding EAN13 In C#.NET
Using Barcode creation for VS .NET Control to generate, create GS1 - 13 image in VS .NET applications.
www.OnBarcode.com
European Article Number 13 Reader In Visual C#.NET
Using Barcode scanner for VS .NET Control to read, scan read, scan image in VS .NET applications.
www.OnBarcode.com
procedure HexExpand( var source: ByteArray; var target: WordArray; byteCount: word ); var index: integer; lowerByte: byte; upperByte: byte; targetIndex: integer; begin
Drawing Barcode In Visual C#.NET
Using Barcode encoder for .NET framework Control to generate, create bar code image in .NET framework applications.
www.OnBarcode.com
Reading Bar Code In Visual C#.NET
Using Barcode scanner for Visual Studio .NET Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
de Complete
Printing EAN-13 In .NET Framework
Using Barcode drawer for ASP.NET Control to generate, create EAN 13 image in ASP.NET applications.
www.OnBarcode.com
Encoding GS1 - 13 In .NET
Using Barcode printer for .NET Control to generate, create GS1 - 13 image in .NET applications.
www.OnBarcode.com
26. Code-Tuning Techniques
Draw GS1 - 13 In VB.NET
Using Barcode maker for .NET framework Control to generate, create EAN 13 image in VS .NET applications.
www.OnBarcode.com
Code 3 Of 9 Drawer In Visual C#.NET
Using Barcode maker for VS .NET Control to generate, create Code 3/9 image in Visual Studio .NET applications.
www.OnBarcode.com
Page 35
1D Barcode Generator In Visual C#.NET
Using Barcode generator for Visual Studio .NET Control to generate, create 1D image in Visual Studio .NET applications.
www.OnBarcode.com
Code 128 Code Set C Maker In Visual C#
Using Barcode creation for .NET framework Control to generate, create ANSI/AIM Code 128 image in VS .NET applications.
www.OnBarcode.com
targetIndex := 1; for index := 1 to byteCount do begin target[ targetIndex ] := ( (source[ index ] and $F0) shr 4 ) + $41; target[ targetIndex+1 ] := (source[ index ] and $0f) + $41; targetIndex := targetIndex + 2; end; end;
Bar Code Drawer In Visual C#
Using Barcode printer for .NET Control to generate, create bar code image in .NET framework applications.
www.OnBarcode.com
Making British Royal Mail 4-State Customer Code In C#
Using Barcode maker for .NET framework Control to generate, create Royal Mail Barcode image in Visual Studio .NET applications.
www.OnBarcode.com
Although it s hard to see where the fat is in this code, it contains a lot of bit manipulation, which isn t exactly Delphi s forte. Bit manipulation is assembler s forte, however, so this code is a good candidate for recoding. Here s the assembler code:
Printing Code-128 In None
Using Barcode printer for Word Control to generate, create USS Code 128 image in Office Word applications.
www.OnBarcode.com
Encode Bar Code In Java
Using Barcode maker for BIRT Control to generate, create barcode image in Eclipse BIRT applications.
www.OnBarcode.com
Example of a Routine Recoded in Assembler
Generate UPC-A In VS .NET
Using Barcode encoder for ASP.NET Control to generate, create UPC Code image in ASP.NET applications.
www.OnBarcode.com
Print UPCA In Objective-C
Using Barcode maker for iPhone Control to generate, create UPC Symbol image in iPhone applications.
www.OnBarcode.com
procedure HexExpand( var source; var target; byteCount : Integer ); label EXPAND; asm MOV MOV MOV XOR EXPAND: MOV MOV MOV AND ADD SHR AND ADD SHL MOV INC LOOP end; EBX,EAX DL,[ESI+EBX] DH,DL DH,$F DH,$41 DL,4 DL,$F DL,$41 BX,1 [EDI+EBX],DX EAX EXPAND // array offset // get source byte // copy source byte // get msbs // add 65 to make upper case // move lsbs into position // get lsbs // add 65 to make upper case // double offset for target array offset // put target word // increment array offset // repeat until finished ECX,byteCount ESI,source EDI,target EAX,EAX // load number of bytes to expand // source offset // target offset // zero out array offset
QR Printer In Java
Using Barcode creator for Eclipse BIRT Control to generate, create QR-Code image in Eclipse BIRT applications.
www.OnBarcode.com
Decode GTIN - 12 In None
Using Barcode recognizer for Software Control to read, scan read, scan image in Software applications.
www.OnBarcode.com
de Complete
Barcode Encoder In Visual Studio .NET
Using Barcode creation for ASP.NET Control to generate, create barcode image in ASP.NET applications.
www.OnBarcode.com
Paint Code128 In None
Using Barcode generation for Office Excel Control to generate, create Code 128A image in Excel applications.
www.OnBarcode.com
26. Code-Tuning Techniques
Page 36
Rewriting in assembler in this case was profitable, resulting in a time savings of 41 percent. It s logical to assume that code in a language that s more suited to bit manipulation C++, for instance would have less to gain than Delphi code would. Here are the results:
HighLevel Time 4.25 5.18
Language C++ Delphi
Assembler Time 3.02 3.04
Time Savings 29% 41%
The before picture in this measurements reflects the two languages strengths at bit manipulation. The after picture looks virtually identical, and it appears that the assembler code has minimized the initial performance differences between Delphi and C++. The assembler routine shows that rewriting in assembler doesn t have to produce a huge, ugly routine. Such routines are often quite modest, as this one is. Sometimes assembler code is almost as compact as its high-level-language equivalent. A relatively easy and effective strategy for recoding in assembler is to start with a compiler that generates assembler listings as a by-product of compilation. Extract the assembler code for the routine you need to tune, and save it in a separate source file. Using the compiler s assembler code as a base, handoptimize the code, checking for correctness and measuring improvements at each step. Some compilers intersperse the high-level-language statements as comments in the assembler code. If yours does, you might keep them in the assembler code as documentation.
CC2E.COM/ 2672
CHECKLIST: Code-Tuning Techniques
Improve Both Speed and Size
Substitute table lookups for complicated logic Jam loops Use integer instead of floating-point variables Initialize data at compile time Use constants of the correct type Precompute results Eliminate common subexpressions Translate key routines to assembler
de Complete
26. Code-Tuning Techniques
Page 37
Improve Speed Only
Stop testing when you know the answer Order tests in case statements and if-then-else chains by frequency Compare performance of similar logic structures Use lazy evaluation Unswitch loops that contain if tests Unroll loops Minimize work performed inside loops Use sentinels in search loops Put the busiest loop on the inside of nested loops Reduce the strength of operations performed inside loops Change multiple-dimension arrays to a single dimension Minimize array references Augment data types with indexes Cache frequently used values Exploit algebraic identities Reduce strength in logical and mathematical expressions Be wary of system routines Rewrite routines in line
26.7 The More Things Change, the More They Stay the Same
You might expect that performance attributes of systems would have changed somewhat in the 10 years since I wrote the first edition of Code Complete, and in some ways they have. Computers are dramatically faster and memory is more plentiful. In the first edition, I ran most of the tests in this chapter 10,000 to 50,000 times to get meaningful, measurable results. For this edition I had to run most tests 1 million to 100 million times. When you have to run a test 100 million times to get measurable results, you have to ask whether anyone will ever notice the impact in a real program. Computers have become so powerful that for many common kinds of programs the level of performance optimization discussed in this chapter has become irrelevant. In other ways, performance issues have hardly changed at all. People writing desktop applications may not need this information, but people writing software
Copyright © OnBarcode.com . All rights reserved.