CARVIEW |
Select Language
HTTP/2 200
date: Sat, 19 Jul 2025 16:56:44 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
etag: W/"b7fad5c679c7d79d8159ff8e71dac40b"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: origin-when-cross-origin, strict-origin-when-cross-origin
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=aYAnekARqAoWCHNcClMxejsLrZo0ukU%2BGrYt2jhbBjuUsJbw92RlwCAd1oDm5vnQcHpuTAqBWInwkMUt%2FK6DqJQF%2FvEuXmGLFi3qmqZL0Czq3qHnqZDQd805hyEdY9vVKD4MOCyO445jauXMs51tW%2FboZJMMD7Qk75CC8VSjUkwOJuB8STVflaBDu8mv17xFpGKUvFlYvoQb4q2wNV%2BZX4raC16cdzTYyJbAUoWEXBT7gjRfuDHL059v%2FjcVNo16ZClFHEHMFZeRLhiTa0DUgw%3D%3D--hb2U7p3m4lDcyt1B--ftd%2B%2Bn2Jin3LsL6zEtS06w%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.2091022368.1752944204; Path=/; Domain=github.com; Expires=Sun, 19 Jul 2026 16:56:44 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Sun, 19 Jul 2026 16:56:44 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: D738:0A55:3F1FC6:4E5F7D:687BCE4C
SBE CarExample Benchmark · GitHub
Show Gist options
Save szehetner/5ed4f7acceedfb8bce092b10f829ba92 to your computer and use it in GitHub Desktop.
{{ message }}
Instantly share code, notes, and snippets.
Created
March 17, 2021 16:02
-
Star
0
(0)
You must be signed in to star a gist -
Fork
0
(0)
You must be signed in to fork a gist
-
Save szehetner/5ed4f7acceedfb8bce092b10f829ba92 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Text; | |
using Baseline; | |
using BenchmarkDotNet.Attributes; | |
using BenchmarkDotNet.Diagnosers; | |
using Org.SbeTool.Sbe.Dll; | |
namespace Org.SbeTool.Sbe.Benchmarks.Bench.Benchmarks | |
{ | |
[HardwareCounters(HardwareCounter.BranchMispredictions, HardwareCounter.BranchInstructions)] | |
[MemoryDiagnoser] | |
public class CarBenchmark | |
{ | |
private static readonly byte[] VehicleCode = Encoding.GetEncoding(Car.VehicleCodeCharacterEncoding).GetBytes("abcdef"); | |
private static readonly byte[] ManufacturerCode = Encoding.GetEncoding(Engine.ManufacturerCodeCharacterEncoding).GetBytes("123"); | |
private static readonly byte[] Manufacturer = Encoding.GetEncoding(Car.ManufacturerCharacterEncoding).GetBytes("Honda"); | |
private static readonly byte[] Model = Encoding.GetEncoding(Car.ModelCharacterEncoding).GetBytes("Civic VTi"); | |
private static readonly byte[] ActivationCode = Encoding.GetEncoding(Car.ActivationCodeCharacterEncoding).GetBytes("abcdef"); | |
private static readonly byte[] UrbanCycle = Encoding.GetEncoding(Car.FuelFiguresGroup.UsageDescriptionCharacterEncoding).GetBytes("Urban Cycle"); | |
private static readonly byte[] CombinedCycle = Encoding.GetEncoding(Car.FuelFiguresGroup.UsageDescriptionCharacterEncoding).GetBytes("Combined Cycle"); | |
private static readonly byte[] HighwayCycle = Encoding.GetEncoding(Car.FuelFiguresGroup.UsageDescriptionCharacterEncoding).GetBytes("Highway Cycle"); | |
private readonly byte[] _eBuffer = new byte[1024]; | |
private readonly byte[] _dBuffer = new byte[1024]; | |
private DirectBuffer _encodeBuffer; | |
private DirectBuffer _decodeBuffer; | |
private readonly Car _car = new Car(); | |
private readonly MessageHeader _messageHeader = new MessageHeader(); | |
[GlobalSetup] | |
public void Setup() | |
{ | |
_encodeBuffer = new DirectBuffer(_eBuffer); | |
_decodeBuffer = new DirectBuffer(_dBuffer); | |
Encode(_car, _decodeBuffer, 0); | |
} | |
[Benchmark] | |
public int Encode() | |
{ | |
return Encode(_car, _encodeBuffer, 0); | |
} | |
[Benchmark] | |
public void Decode() | |
{ | |
Decode(_car, _decodeBuffer, 0); | |
} | |
public int Encode(Car car, DirectBuffer directBuffer, int bufferOffset) | |
{ | |
_car.WrapForEncodeAndApplyHeader(directBuffer, 0, _messageHeader); | |
const int srcOffset = 0; | |
car.SerialNumber = 1234; | |
car.ModelYear = 2013; | |
car.Available = BooleanType.T; | |
car.Code = Baseline.Model.A; | |
car.SetVehicleCode(VehicleCode, srcOffset); | |
for (int i = 0, size = Car.SomeNumbersLength; i < size; i++) | |
{ | |
car.SetSomeNumbers(i, (uint)i); | |
} | |
car.Extras = OptionalExtras.CruiseControl | OptionalExtras.SportsPack; | |
car.Engine.Capacity = 2000; | |
car.Engine.NumCylinders = 4; | |
car.Engine.SetManufacturerCode(ManufacturerCode, srcOffset); | |
car.Engine.Efficiency = 35; | |
car.Engine.BoosterEnabled = BooleanType.T; | |
car.Engine.Booster.BoostType = BoostType.NITROUS; | |
car.Engine.Booster.HorsePower = 200; | |
var fuelFigures = car.FuelFiguresCount(3); | |
fuelFigures.Next(); | |
fuelFigures.Speed = 30; | |
fuelFigures.Mpg = 35.9f; | |
fuelFigures.SetUsageDescription(UrbanCycle); | |
fuelFigures.Next(); | |
fuelFigures.Speed = 55; | |
fuelFigures.Mpg = 49.0f; | |
fuelFigures.SetUsageDescription(CombinedCycle); | |
fuelFigures.Next(); | |
fuelFigures.Speed = 75; | |
fuelFigures.Mpg = 40.0f; | |
fuelFigures.SetUsageDescription(HighwayCycle); | |
Car.PerformanceFiguresGroup perfFigures = car.PerformanceFiguresCount(2); | |
perfFigures.Next(); | |
perfFigures.OctaneRating = 95; | |
Car.PerformanceFiguresGroup.AccelerationGroup acceleration = perfFigures.AccelerationCount(3).Next(); | |
acceleration.Mph = 30; | |
acceleration.Seconds = 4.0f; | |
acceleration.Next(); | |
acceleration.Mph = 60; | |
acceleration.Seconds = 7.5f; | |
acceleration.Next(); | |
acceleration.Mph = 100; | |
acceleration.Seconds = 12.2f; | |
perfFigures.Next(); | |
perfFigures.OctaneRating = 99; | |
acceleration = perfFigures.AccelerationCount(3).Next(); | |
acceleration.Mph = 30; | |
acceleration.Seconds = 3.8f; | |
acceleration.Next(); | |
acceleration.Mph = 60; | |
acceleration.Seconds = 7.1f; | |
acceleration.Next(); | |
acceleration.Mph = 100; | |
acceleration.Seconds = 11.8f; | |
car.SetManufacturer(Manufacturer, srcOffset, Manufacturer.Length); | |
car.SetModel(Model, srcOffset, Model.Length); | |
car.SetActivationCode(ActivationCode, srcOffset, ActivationCode.Length); | |
return car.Size; | |
} | |
private readonly byte[] _buffer = new byte[128]; | |
public void Decode(Car car, DirectBuffer directBuffer, int bufferOffset) | |
{ | |
_messageHeader.Wrap(directBuffer, 0, 0); | |
car.WrapForDecode(directBuffer, bufferOffset + MessageHeader.Size, _messageHeader.BlockLength, _messageHeader.Version); | |
var templateId = Car.TemplateId; | |
var schemaVersion = Car.SchemaVersion; | |
var serialNumber = car.SerialNumber; | |
var modelYear = car.ModelYear; | |
var available = car.Available; | |
var code = car.Code; | |
for (int i = 0, size = Car.SomeNumbersLength; i < size; i++) | |
{ | |
var number = car.GetSomeNumbers(i); | |
} | |
car.GetVehicleCode(_buffer, 0); | |
OptionalExtras extras = car.Extras; | |
var cruiseControl = (extras & OptionalExtras.CruiseControl) == OptionalExtras.CruiseControl; | |
var sportsPack = (extras & OptionalExtras.SportsPack) == OptionalExtras.SportsPack; | |
var sunRoof = (extras & OptionalExtras.SunRoof) == OptionalExtras.SunRoof; | |
Engine engine = car.Engine; | |
var capacity = engine.Capacity; | |
var numCylinders = engine.NumCylinders; | |
var maxRpm = engine.MaxRpm; | |
for (int i = 0, size = Engine.ManufacturerCodeLength; i < size; i++) | |
{ | |
engine.GetManufacturerCode(i); | |
} | |
int length = engine.GetFuel(_buffer, 0, _buffer.Length); | |
var efficiency = engine.Efficiency; | |
var boosterEnabled = engine.BoosterEnabled; | |
var boostType = engine.Booster.BoostType; | |
var horsePower = engine.Booster.HorsePower; | |
var fuelFiguresGroup = car.FuelFigures; | |
while (fuelFiguresGroup.HasNext) | |
{ | |
var fuelFigures = fuelFiguresGroup.Next(); | |
var speed = fuelFigures.Speed; | |
var mpg = fuelFigures.Mpg; | |
fuelFigures.GetUsageDescription(_buffer, 0, _buffer.Length); | |
} | |
var performanceFiguresGroup = car.PerformanceFigures; | |
while (performanceFiguresGroup.HasNext) | |
{ | |
performanceFiguresGroup.Next(); | |
var octanceRating = performanceFiguresGroup.OctaneRating; | |
var accelerationGroup = performanceFiguresGroup.Acceleration; | |
for (int i = 0; i < accelerationGroup.Count; i++) | |
{ | |
var acceleration = accelerationGroup.Next(); | |
var mpg = acceleration.Mph; | |
var seconds = acceleration.Seconds; | |
} | |
} | |
length = car.GetManufacturer(_buffer, 0, _buffer.Length); | |
length = car.GetModel(_buffer, 0, _buffer.Length); | |
length = car.GetActivationCode(_buffer, 0, _buffer.Length); | |
var totalSize = car.Size; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can’t perform that action at this time.