Skip to content

Commit 0596f8b

Browse files
Update to ReadMe.
1 parent 623f66d commit 0596f8b

1 file changed

Lines changed: 115 additions & 3 deletions

File tree

README.md

Lines changed: 115 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ Each time the Parser calls back to the client code, it provides a ResolvedApplic
152152

153153
### Performance
154154

155-
The GS1 AI Parser is a high-performance library. As far as possible, parsing operations are carried out on the stack and heap allocations are avoided. This significantly increases the performance of the library and avoids unnecessary garbage collection.
155+
The GS1 AI Parser is a high-performance library. As far as possible, parsing operations are carried out on the stack and heap allocations are avoided. This significantly increases the performance of the library and avoids unnecessary garbage collection. Internally, modern versions of .NET use SIMD instructions where appropriate to further boost performance.
156156

157157

158158

@@ -164,9 +164,9 @@ If the client application is written using the older .NET Framework, it will not
164164

165165

166166

167-
To eliminate heap allocations, use ParseEx(). This method is supported only on the .NET 7.0 platform, or higher. Again, there is little difference in performance. However, ParseEx() invokes a ResolvedElementDelegate, passing a ResolvedApplicationIdentifierRef ref struct which lives on the stack.
167+
To eliminate heap allocations, use ParseEx(). This method is supported only on the .NET 7.0 platform, or higher. ParseEx() does not generally provide any significant performance improvement. However, it invokes a ResolvedElementDelegate, passing a ResolvedApplicationIdentifierRef ref struct which lives on the stack. ParseEx() is only recommended for use in systems that require reliable high-performance and real-time processing.
168+
168169

169-
 
170170

171171
As a broad indication of performance, you could reasonably expect, in an ideal scenario, that a modern CPU can parse 600,000 - 800,000 instances per second of valid barcode data containing four GS1 entities (e.g., unique identifiers on the secondary packaging of medicinal products). Of course, actual performance will depend on other factors, including the version of .NET, the number of errors detected in the barcode data, the performance of your client code, CPU and memory specifications, environmental load on the CPU, etc.
172172

@@ -191,6 +191,118 @@ Performance drops when data relationship rules are performed. Memory allocations
191191

192192

193193

194+
The library is not compiled using pre-jitting ('ready-to-run' - requires the .NET runtime). This could be useful to maximise performance in scenarios where the parser is instantiated and invoked in a one-shot manner. While it is possible to publish multiple pre-jitted images in a NuGet package, there are limitations which make the package harder to use. If you need to pre-jit the code, try pre-jitting your client code. Alternatively, compile and publish the source code yourself. For example, to publish for the Win-64 platform, use the following command lines:
195+
196+
197+
198+
dotnet restore -p:PublishReadyToRun=true
199+
200+
dotnet publish .\\Solidsoft.Reply.Parsers.Gs1Ai.csproj -c Release -f net7.0 -r win-x64 -p:PublishReadyToRun=true
201+
202+
203+
204+
### Interoperability
205+
206+
207+
208+
The GS1 parser library is CLS-compliant, ensuring good interoperability across different .NET languages.
209+
210+
211+
212+
#### Native Code Library
213+
214+
Modern versions of .NET provide good support for AOT (Ahead-of-Time) Native code generation. The generated code targets a specific platform (e.g., win-x64) and runs independently of the .NET runtime. Native code libraries can be used by a wide range of compiler technologies, bytecode environments (Java, WASM etc.) and languages. To facilitate this approach to interoperability, we provide the Solidsoft.Reply.Parsers.Gs1Ai.Native.win-x64 project. This project is configured to publish a native code library for win-x64. To build the code, you must ensure you have the correct toolchain installed. For example, Visual Studio users can include the 'Desktop development with C++' workload in their Visual Studio installation to build the code for the win-x64 target platform. See https://learn.microsoft.com/uk-ua/dotnet/core/deploying/native-aot/?tabs=windows%2Cnet8 for additional information. To demonstrate the use of the native code generated by this project, we have included the Solidsoft.Reply.Parsers.Gs1Ai.Native.Tester project. This is a C++ Console application that demonstrates the use of the native GS1 Parser library.
215+
216+
217+
218+
The native code library exports three functions as a C ABI:
219+
220+
221+
222+
Gs1Ai\_Callback
223+
224+
Gs1Ai\_SetExceptionCallback
225+
226+
Gs1Ai\_Parse
227+
228+
229+
230+
Use the first two functions to set the main call-back and an additional call-back for exceptions. Then use Gs1\_Parse to parse the input string.
231+
232+
233+
234+
void \_\_stdcall Gs1Ai\_Callback(
235+
236+
  wchar\_t\*, // identifier (UTF-16 on Windows)
237+
238+
  int, // length of identifier
239+
240+
  wchar\_t\*, // value (UTF-16 on Windows)
241+
242+
  int, // length of value
243+
244+
  int, // entity
245+
246+
  wchar\_t\*, // Data title (UTF-16 on Windows)
247+
248+
  int, // Length of data title
249+
250+
  wchar\_t\*, // Description (UTF-16 on Windows)
251+
252+
  int, // Length of description
253+
254+
  int, // Inverse exponent
255+
256+
  int, // Sequence
257+
258+
  int, // Is fixed width (1 = true, 0 = false)
259+
260+
  int,  // Is error (1 = true, 0 = false)
261+
262+
  int,  // Is fatal (1 = true, 0 = false)
263+
264+
  int, // Character position
265+
266+
  int) // Index
267+
268+
269+
270+
void \_\_stdcall Gs1Ai\_SetExceptionCallback(
271+
272+
  int, // Entity
273+
274+
  int, // Error number
275+
276+
  wchar\_t\*,   // Message (UTF-16 on Windows)
277+
278+
  int,   // length of message
279+
280+
  int,    // Is fatal (1 = true, 0 = false)
281+
282+
  int) // Offset
283+
284+
285+
286+
int \_\_stadcall Gs1Ai\_Parse(
287+
288+
  wchar\_t\*, // Input (UTF-16 on Windows)
289+
290+
  int, // Length of input
291+
292+
  int, // Relationship Tests - 0 = None, 1 = Invalid pairs, 2 = All
293+
294+
  int, // GTIN semantics = 0 = General, 1 = Variable Measure, 2 = Custom
295+
296+
  int, // Expiry Date semantics - 0 = Trade Item, 1 = Coupon
297+
298+
  int, // Amount Payable semantics - 0 = Invoice, 1 - Coupon Value
299+
300+
  const wchar\_t\*\*, // GCP list (UTF-16 on Windows)
301+
302+
  int) // Count of GCPs in list
303+
304+
305+
194306
### Validation Errors and Warnings
195307

196308
The GS1 Parser raises errors and warnings in the range of 2000-2499. Each error is categorised as fatal or non-fatal. Warnings are always non-fatal.

0 commit comments

Comments
 (0)