forked from pulumi/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into lambda-callback-update
- Loading branch information
Showing
21 changed files
with
752 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using Pulumi; | ||
|
||
public class Dummy : ComponentResource | ||
{ | ||
[Output] | ||
public Output<string> Deadweight { get; private set; } = null!; | ||
|
||
public Dummy(string name, Input<string> deadweight, ComponentResourceOptions? options = null) | ||
: base("examples:dummy:Dummy", name, options) | ||
{ | ||
this.Deadweight = deadweight; | ||
|
||
this.RegisterOutputs(); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Collections.Generic; | ||
using System.Collections.Immutable; | ||
|
||
using Pulumi; | ||
|
||
class MyStack : Stack | ||
{ | ||
[Output] | ||
public Output<int> ResourceCount { get; set; } | ||
|
||
[Output] | ||
public Output<int> ResourcePayloadBytes { get; set; } | ||
|
||
public MyStack() | ||
{ | ||
var config = new Config(); | ||
int resourceCount = config.RequireInt32("resource_count"); | ||
int resourcePayloadBytes = config.RequireInt32("resource_payload_bytes"); | ||
|
||
Output<int> resourcePayloadBytesOutput = Output.Create(resourcePayloadBytes); | ||
|
||
for (var i = 0; i < resourceCount; i++) { | ||
string deadweight = String.Concat(Enumerable.Repeat( | ||
String.Format("{0:00000000}", i), | ||
resourcePayloadBytes/8)); | ||
Dummy dummy = new Dummy($"dummy-{i}", deadweight); | ||
resourcePayloadBytesOutput = dummy.Deadweight.Apply(w => w.Length); | ||
} | ||
|
||
this.ResourceCount = Output.Create(resourceCount); | ||
this.ResourcePayloadBytes = resourcePayloadBytesOutput; | ||
} | ||
|
||
private static int GetEnv(string name, int defaultValue) | ||
{ | ||
var v = System.Environment.GetEnvironmentVariable(name); | ||
return v == null ? defaultValue : int.Parse(v); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
using System.Threading.Tasks; | ||
using Pulumi; | ||
|
||
class Program | ||
{ | ||
static Task<int> Main() => Deployment.RunAsync<MyStack>(); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name: cs-many-resources | ||
runtime: dotnet | ||
description: A minimal C# Pulumi program |
13 changes: 13 additions & 0 deletions
13
misc/benchmarks/cs-many-resources/cs-many-resources.csproj
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Pulumi" Version="3.*" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name: go-many-resources | ||
runtime: go | ||
description: A benchmark to test performance of stacks with many resources |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi" | ||
) | ||
|
||
type Dummy struct { | ||
pulumi.ResourceState | ||
|
||
Deadweight pulumi.StringOutput `pulumi:"deadweight"` | ||
} | ||
|
||
type DummyArgs struct { | ||
Deadweight pulumi.StringInput | ||
} | ||
|
||
func NewDummy(ctx *pulumi.Context, name string, args *DummyArgs, opts ...pulumi.ResourceOption) (*Dummy, error) { | ||
dummy := &Dummy{} | ||
err := ctx.RegisterComponentResource("examples:dummy:Dummy", name, dummy, opts...) | ||
if err != nil { | ||
return nil, err | ||
} | ||
dummy.Deadweight = args.Deadweight.ToStringOutput() | ||
ctx.RegisterResourceOutputs(dummy, pulumi.Map{ | ||
"deadweight": dummy.Deadweight, | ||
}) | ||
return dummy, nil | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module go-many-resources | ||
|
||
go 1.14 | ||
|
||
require ( | ||
github.com/pulumi/pulumi/sdk/v3 v3.6.1 | ||
) |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi" | ||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config" | ||
) | ||
|
||
func main() { | ||
pulumi.Run(func(ctx *pulumi.Context) error { | ||
conf := config.New(ctx, "") | ||
resourceCount := conf.RequireInt("resource_count") | ||
resourcePayloadBytes := conf.RequireInt("resource_payload_bytes") | ||
|
||
for i := 0; i < resourceCount; i++ { | ||
deadweight := strings.Repeat(fmt.Sprintf("%08d", i), resourcePayloadBytes/8) | ||
|
||
dummy, err := NewDummy(ctx, fmt.Sprintf("dummy-%d", i), &DummyArgs{ | ||
Deadweight: pulumi.String(deadweight), | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if i == 0 { | ||
ctx.Export("ResourcePayloadBytes", dummy.Deadweight.ApplyT(func(x string) int { | ||
return len(x) | ||
})) | ||
} | ||
} | ||
|
||
ctx.Export("ResourceCount", pulumi.Int(resourceCount)) | ||
return nil | ||
}) | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
name: py-many-resources | ||
runtime: | ||
name: python | ||
options: | ||
virtualenv: venv | ||
description: A benchmark to test performance of stacks with many resources |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import os | ||
import pulumi | ||
|
||
from dummy import Dummy | ||
|
||
config = pulumi.Config(); | ||
|
||
resource_count = config.require_int('resource_count') | ||
resource_payload_bytes = config.require_int('resource_payload_bytes') | ||
|
||
for i in range(0, resource_count): | ||
deadweight = '{:08}'.format(i) * int(resource_payload_bytes / 8) | ||
dummy = Dummy(f'dummy-{i}', deadweight=deadweight) | ||
if i == 0: | ||
pulumi.export('ResourcePayloadBytes', dummy.deadweight.apply(lambda s: len(s))) | ||
|
||
pulumi.export('ResourceCount', resource_count) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import pulumi | ||
|
||
|
||
class Dummy(pulumi.ComponentResource): | ||
|
||
def __init__(self, name, deadweight, opts=None): | ||
super().__init__('examples:dummy:Dummy', name, {'deadweight': deadweight}, opts) | ||
|
||
self.deadweight = pulumi.Output.from_input(deadweight) | ||
self.register_outputs({'deadweight': self.deadweight}) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pulumi>=3.0.0,<4.0.0 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name: ts-many-resources | ||
runtime: nodejs | ||
description: A minimal TypeScript Pulumi program |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import * as pulumi from "@pulumi/pulumi"; | ||
|
||
export class Dummy extends pulumi.ComponentResource { | ||
public deadweight: pulumi.Output<string>; | ||
|
||
constructor(name: string, deadweight: pulumi.Input<string>, opts: pulumi.ComponentResourceOptions = {}) { | ||
super("examples:dummy:Dummy", name, {'deadweight': deadweight}, opts); | ||
|
||
this.deadweight = pulumi.Output.create(deadweight); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import * as pulumi from "@pulumi/pulumi"; | ||
|
||
import { Dummy } from "./dummy"; | ||
|
||
const config = new pulumi.Config(); | ||
|
||
const resourceCount: number = config.requireNumber("resource_count"); | ||
const resourcePayloadBytes: number = config.requireNumber("resource_payload_bytes"); | ||
|
||
function pad8(num: number): string { | ||
return ('00000000' + num).slice(-8); | ||
} | ||
|
||
function newDummy(i: number): Dummy { | ||
const deadweight = pad8(i).repeat(resourcePayloadBytes/8); | ||
return new Dummy(`dummy-${i}`, deadweight); | ||
} | ||
|
||
export const ResourceCount = resourceCount; | ||
|
||
const dummy0 = newDummy(0); | ||
|
||
export const ResourcePayloadBytes = dummy0.deadweight.apply(x => x.length); | ||
|
||
for (var i = 1; i < resourceCount; i++) { | ||
newDummy(i) | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "ts-many-resources", | ||
"devDependencies": { | ||
"@types/node": "^10.0.0" | ||
}, | ||
"dependencies": { | ||
"@pulumi/pulumi": "^3.0.0" | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"compilerOptions": { | ||
"strict": true, | ||
"outDir": "bin", | ||
"target": "es2016", | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"sourceMap": true, | ||
"experimentalDecorators": true, | ||
"pretty": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"noImplicitReturns": true, | ||
"forceConsistentCasingInFileNames": true | ||
}, | ||
"files": [ | ||
"index.ts" | ||
] | ||
} |
This file contains 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