Skip to content

Commit

Permalink
Aggressive Inlining
Browse files Browse the repository at this point in the history
  • Loading branch information
AntyaDev committed Nov 24, 2022
1 parent c39627c commit b149b26
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
17 changes: 10 additions & 7 deletions src/NBomber/Api/CSharp.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ open NBomber.Contracts.Internal

type Response =

[<MethodImpl(MethodImplOptions.AggressiveInlining)>]
static member Ok() = ResponseInternal.okEmpty

[<MethodImpl(MethodImplOptions.AggressiveInlining)>]
static member Fail() = ResponseInternal.failEmpty<obj>

static member Ok(
static member inline Ok(
[<Optional;DefaultParameterValue("")>] statusCode: string,
[<Optional;DefaultParameterValue(0)>] sizeBytes: int,
[<Optional;DefaultParameterValue("")>] message: string,
Expand All @@ -30,7 +33,7 @@ type Response =
Message = if isNull message then String.Empty else message
Payload = None }

static member Ok<'T>(
static member inline Ok<'T>(
[<Optional;DefaultParameterValue("")>] statusCode: string,
[<Optional;DefaultParameterValue(0)>] sizeBytes: int,
[<Optional;DefaultParameterValue("")>] message: string,
Expand All @@ -43,7 +46,7 @@ type Response =
Message = if isNull message then String.Empty else message
Payload = None }

static member Ok<'T>(
static member inline Ok<'T>(
payload: 'T,
[<Optional;DefaultParameterValue("")>] statusCode: string,
[<Optional;DefaultParameterValue(0)>] sizeBytes: int,
Expand All @@ -57,7 +60,7 @@ type Response =
Message = if isNull message then String.Empty else message
Payload = Some payload }

static member Fail(
static member inline Fail(
[<Optional;DefaultParameterValue("")>] statusCode: string,
[<Optional;DefaultParameterValue("")>] message: string,
[<Optional;DefaultParameterValue(0)>] sizeBytes: int,
Expand All @@ -70,7 +73,7 @@ type Response =
Message = if isNull message then String.Empty else message
Payload = None }

static member Fail<'T>(
static member inline Fail<'T>(
[<Optional;DefaultParameterValue("")>] statusCode: string,
[<Optional;DefaultParameterValue("")>] message: string,
[<Optional;DefaultParameterValue(0)>] sizeBytes: int,
Expand All @@ -83,7 +86,7 @@ type Response =
Message = if isNull message then String.Empty else message
Payload = None }

static member Fail<'T>(
static member inline Fail<'T>(
payload: 'T,
[<Optional;DefaultParameterValue("")>] statusCode: string,
[<Optional;DefaultParameterValue("")>] message: string,
Expand All @@ -102,7 +105,7 @@ type Step =

/// Runs a step.
/// Step represents a single user action like login, logout, etc.
static member Run(name: string, context: IScenarioContext, run: Func<Task<Response<'T>>>) =
static member inline Run(name: string, context: IScenarioContext, run: Func<Task<Response<'T>>>) =
FSharp.Step.run(name, context, run.Invoke)

/// Scenario is basically a workflow that virtual users will follow. It helps you organize steps into user actions.
Expand Down
8 changes: 6 additions & 2 deletions src/NBomber/Api/FSharp.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
open System
open System.IO
open System.Runtime
open System.Runtime.CompilerServices
open System.Threading.Tasks

open Serilog
Expand All @@ -22,10 +23,13 @@ open NBomber.DomainServices

type Response =

[<MethodImpl(MethodImplOptions.AggressiveInlining)>]
static member ok () = ResponseInternal.okEmpty

[<MethodImpl(MethodImplOptions.AggressiveInlining)>]
static member fail () = ResponseInternal.failEmpty<obj>

static member ok<'T>(
static member inline ok<'T>(
?payload: 'T,
?statusCode: string,
?sizeBytes: int,
Expand All @@ -39,7 +43,7 @@ type Response =
Message = message |> Option.defaultValue ""
Payload = payload }

static member fail<'T>(
static member inline fail<'T>(
?statusCode: string,
?message: string,
?payload: 'T,
Expand Down
2 changes: 1 addition & 1 deletion src/NBomber/Domain/ScenarioContext.fs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type ScenarioContext(scenarioInfo, args: ScenarioContextArgs) =
member _.StatsActor = _scnActor
member _.Timer = _timer

member _.PrepareNextIteration() =
member inline _.PrepareNextIteration() =
_invocationNumber <- _invocationNumber + 1
_data.Clear()

Expand Down

0 comments on commit b149b26

Please sign in to comment.