Send "Number like string" through network

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By liss22

Hi,
Theseday, I use godot as network server (fast build for demo server)

Question about optimization

Situation

  1. Game will send data in realtime (means send at least 30 packets per second)
    (optional) 2. Data always be ( JSON-stringify )
    Have some form for kind of contents, but will be JSON in demo play

I want to optimize sending/receiving amount.
and wonder,

Is sending ‘Number like string’ as Number is better than as String?

Sending “1234567890” as string VS 1234567890 as int

In godot,
Int is ‘Signed 64-bit integer type’
String may kind of ‘Object’

which is cheap?

*Optional situation can be delete if it cause optimization more

:bust_in_silhouette: Reply From: nonunknown

well if what are sending will be always a number and its not a decimal number, only a integer according to Signed 64-bit integer type sending it is cheaper.

also if you are going to send 30 packets per second you should not use a JSON, nor TCP connection, but instead, UDP connection and convert all to PoolByteArray

Thank you for your advice :slight_smile:

liss22 | 2020-08-04 07:42