Skip to content

Instantly share code, notes, and snippets.

View paulbatum's full-sized avatar

Paul Batum paulbatum

View GitHub Profile
@paulbatum
paulbatum / BCryptTest.cs
Created November 24, 2017 19:02
Functions Tiered Jit Test
using System.IO;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Azure.WebJobs.Host;
using Newtonsoft.Json;
namespace TieredJitTest
@paulbatum
paulbatum / EventHubTrigger.csx
Created October 11, 2017 21:00
Setting PartitionKey in Azure Functions
#r "Microsoft.ServiceBus"
using System;
using System.Text;
using Microsoft.ServiceBus.Messaging;
public static void Run(EventData myEventHubMessage, TraceWriter log)
{
log.Info($"C# Event Hub trigger function processed a message with partition key: {myEventHubMessage.PartitionKey}");
}
@paulbatum
paulbatum / costcalculator.cs
Last active July 12, 2022 15:27
Azure Functions pricing calculation
const decimal executionCountCost = 0.20m / 1000000m;
const decimal gbSecCost = 0.000016m;
const decimal executionUnitsToGbSecConversion = 1m / (1024 * 1000);
long executionCountPerHour = 6500012;
long executionUnitsPerHour = 90305037184;
int runDurationDays = 9;
Console.WriteLine("All prices in USD");
@paulbatum
paulbatum / sensors.proto
Created September 14, 2017 19:45
Protocol buffers example
syntax = "proto3";
package sensors;
import "google/protobuf/timestamp.proto";
option csharp_namespace = "EventHubsThroughput.Models.Protobuf";
enum SensorType {
UNKNOWN = 0;
SEISMIC = 1;
WEATHER = 2;
@paulbatum
paulbatum / results.md
Last active July 19, 2017 01:29
Functions min threads fix results

HTTP latency in milliseconds @ 50 RPS

Each row is a 5 minute run at constant load of 50 RPS.

Scenario Min Median P95 P99 Max
Dedicated without fix 154 158.1 999.6 2128 3341.9
Dedicated without fix 154.2 158.8 1204.8 2058.8 3845.8
Dedicated without fix 154 158.6 941 2430.4 4618.1
Dedicated without fix 154.2 158.8 882.1 2089.3 3515.9
@paulbatum
paulbatum / run.csx
Created December 27, 2016 18:59
Functions parallelism
using System.Net;
using System.Threading.Tasks.Dataflow;
public enum Mode
{
Sequential,
Batches,
Dataflow
}
@paulbatum
paulbatum / template.json
Created December 1, 2016 23:41
Consumption function app from github repo ARM template
{
"parameters": {
"name": {
"type": "string"
}
},
"resources": [
{
"apiVersion": "2015-08-01",
"name": "[parameters('name')]",
{
"parameters": {
"name": {
"type": "string",
"defaultValue": "pbsynctest4"
},
"storageName": {
"type": "string",
"defaultValue": "pbsynctest4"
},
@paulbatum
paulbatum / runnerapp-function.json
Last active September 17, 2016 00:37
Function Updater
{
"bindings": [
{
"name": "myTimer",
"type": "timerTrigger",
"direction": "in",
"schedule": "*/10 * * * * *"
},
{
"type": "table",
using System;
using System.Threading.Tasks;
using System.Diagnostics;
static Dictionary<int,byte[]> Allocations = new Dictionary<int,byte[]>();
public static async Task Run(string id, int message, TraceWriter log)
{
log.Verbose($"Machine: {Environment.MachineName}");