[#5] Avoid payload copy in put methods

With goja.ArrayBuffer type VU won't perform
copy operation during every put invocation.

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2022-05-20 14:14:50 +03:00 committed by Alex Vanin
parent b17261cc3c
commit 1c0abb2479
4 changed files with 8 additions and 6 deletions

View file

@ -1,7 +1,7 @@
import { uuidv4 } from 'https://jslib.k6.io/k6-utils/1.2.0/index.js';
import native from 'k6/x/neofs/native';
const payload = new Uint8Array(open('../go.sum', 'b'));
const payload = open('../go.sum', 'b');
const container = "AjSxSNNXbJUDPqqKYm1VbFVDGCakbpUNH8aGjPmGAH3B"
const neofs_cli = native.connect("s01.neofs.devenv:8080", "")

View file

@ -1,7 +1,7 @@
import { uuidv4 } from 'https://jslib.k6.io/k6-utils/1.2.0/index.js';
import s3 from 'k6/x/neofs/s3';
const payload = new Uint8Array(open('../go.sum', 'b'));
const payload = open('../go.sum', 'b');
const bucket = "cats"
const s3_cli = s3.connect("http://s3.neofs.devenv:8080")

View file

@ -5,6 +5,7 @@ import (
"crypto/ecdsa"
"time"
"github.com/dop251/goja"
"github.com/nspcc-dev/neofs-sdk-go/client"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
"github.com/nspcc-dev/neofs-sdk-go/object"
@ -37,8 +38,8 @@ type (
}
)
func (c *Client) Put(inputContainerID string, headers map[string]string, payload []byte) PutResponse {
rdr := bytes.NewReader(payload)
func (c *Client) Put(inputContainerID string, headers map[string]string, payload goja.ArrayBuffer) PutResponse {
rdr := bytes.NewReader(payload.Bytes())
sz := rdr.Size()
// preparation stage

View file

@ -7,6 +7,7 @@ import (
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/dop251/goja"
"github.com/nspcc-dev/xk6-neofs/internal/stats"
"go.k6.io/k6/js/modules"
"go.k6.io/k6/metrics"
@ -29,8 +30,8 @@ type (
}
)
func (c *Client) Put(bucket, key string, payload []byte) PutResponse {
rdr := bytes.NewReader(payload)
func (c *Client) Put(bucket, key string, payload goja.ArrayBuffer) PutResponse {
rdr := bytes.NewReader(payload.Bytes())
sz := rdr.Size()
stats.Report(c.vu, objPutTotal, 1)