Browse Source

添加测试用例和对比

master
AICells 5 years ago
parent
commit
90ce884920
10 changed files with 2524 additions and 81 deletions
  1. +171
    -0
      README.md
  2. +8
    -0
      proto/0_test.mpdf
  3. +8
    -7
      src/protoGen.erl
  4. +117
    -0
      test/gpb/gpb.hrl
  5. +2016
    -0
      test/gpb/mytest.erl
  6. +59
    -0
      test/gpb/mytest.hrl
  7. +33
    -0
      test/gpb/mytest.proto
  8. +4
    -42
      test/protoMsg.erl
  9. +8
    -0
      test/protoMsg.hrl
  10. +100
    -32
      test/test.erl

+ 171
- 0
README.md View File

@ -112,4 +112,175 @@ Build
### 关于消息接收转发解码和发送
erlang通常会将接收到的消息由网关进程转发给其他工作进程, 建议先匹配消息id, 然后转发二进制消息到工作进程,然后由工作进程解码再处理
同时广播消息可先编码成二进制之后再广播, 避免重复编码
### 简单性能测评
主要和gpb做简单对比测试
gpb测试相关文件在test/gpb目录下
测试协议:
gpb:
message test {
required string aa = 1;
}
message phoneNumber {
required test number = 1;
required int32 type = 2;
}
message person {
required string name = 1;
required int32 integer = 2;
optional string email = 3;
repeated phoneNumber phone = 4;
}
message addressBook {
repeated person person1 = 1;
repeated person others = 2;
}
message tint32 {
required int32 int1 = 1;
required int32 int2 = 2;
required int32 int3 = 3;
required int32 int4 = 4;
required int32 int5 = 5;
required int32 int6 = 6;
required int32 int7 = 7;
required int32 int8 = 8;
required int32 int9 = 9;
required int32 int10 = 10;
}
genProto用的协议:
test {
string aa;
}
phoneNumber{
test number;
int32 type;
}
person{
string name;
int32 id;
string email;
list[phoneNumber] phone;
}
addressBook {
list[person] person;
list[person] other;
}
tint32{
int32 int1;
int32 int2;
int32 int3;
int32 int4;
int32 int5;
int32 int6;
int32 int7;
int32 int8;
int32 int9;
int32 int10;
}
测试运行三次 每次100万次循环
tint32 gpb-------->>
tint32 encode:
> timer:tc(mytest, encode_int32, [1000000]).
{9625000,ok}
> timer:tc(mytest, encode_int32, [1000000]).
{9000000,ok}
> timer:tc(mytest, encode_int32, [1000000]).
{9969000,ok}
tin32 decode:
> timer:tc(mytest, decode_int32, [1000000]).
{6217994,ok}
> timer:tc(mytest, decode_int32, [1000000]).
{6187993,ok}
> timer:tc(mytest, decode_int32, [1000000]).
{6265994,ok}
size:
> BTInt32 = mytest:decode_int32(1).
<<8,1,16,255,255,255,255,255,255,255,255,255,1,24,128,1,
32,128,255,255,255,255,255,255,255,255,1,40,128,...>>
31> byte_size(BTInt32).
74
tint32 genProto ------->>
tint32 encode:
> timer:tc(test, encode_int32, [1000000]).
{328999,ok}
> timer:tc(test, encode_int32, [1000000]).
{328000,ok}
> timer:tc(test, encode_int32, [1000000]).
{344000,ok}
tint32 decode:
> timer:tc(test, decode_int32, [1000000]).
{328000,ok}
> timer:tc(test, decode_int32, [1000000]).
{328000,ok}
> timer:tc(test, decode_int32, [1000000]).
{329000,ok}
size:
> BTInt32 = test:decode_int32(1).
<<0,11,0,0,0,1,255,255,255,255,0,0,0,128,255,255,255,128,
0,1,0,0,255,255,0,0,125,43,117,...>>
> byte_size(BTInt32).
42
===============================================================================
===============================================================================
addressBook gpb-------->>
addressBook encode:
> timer:tc(mytest, encode_addressBook, [1000000]).
{9108990,ok}
> timer:tc(mytest, encode_addressBook, [1000000]).
{8999991,ok}
> timer:tc(mytest, encode_addressBook, [1000000]).
{9031991,ok}
addressBook decode:
> timer:tc(mytest, decode_addressBook, [1000000]).
{5702995,ok}
> timer:tc(mytest, decode_addressBook, [1000000]).
{5764994,ok}
> timer:tc(mytest, decode_addressBook, [1000000]).
{5718995,ok}
size:
> BAddr = mytest:decode_addressBook(1).
<<10,43,10,5,65,108,105,99,101,16,144,78,34,15,10,11,10,9,
49,50,51,52,53,54,55,56,57,16,1,...>>
> byte_size(BAddr).
75
addressBook genProto -------->>
addressBook encode:
> timer:tc(test, encode_addressBook, [1000000]).
{4186995,ok}
> timer:tc(test, encode_addressBook, [1000000]).
{4202996,ok}
> timer:tc(test, encode_addressBook, [1000000]).
{4202996,ok}
addressBook decode:
> timer:tc(test, decode_addressBook, [1000000]).
{2749997,ok}
> timer:tc(test, decode_addressBook, [1000000]).
{2812997,ok}
> timer:tc(test, decode_addressBook, [1000000]).
{2812997,ok}
size:
BAddr = test:decode_addressBook(1).
<<0,4,0,2,0,5,65,108,105,99,101,0,0,39,16,0,0,0,2,1,0,9,
49,50,51,52,53,54,55,...>>
67> byte_size(BAddr).
83

+ 8
- 0
proto/0_test.mpdf View File

@ -57,6 +57,14 @@ tuint16{
tint32{
int32 int1;
int32 int2;
int32 int3;
int32 int4;
int32 int5;
int32 int6;
int32 int7;
int32 int8;
int32 int9;
int32 int10;
}
tuint32{

+ 8
- 7
src/protoGen.erl View File

@ -250,12 +250,13 @@ genEncodeRec({MsgName, MsgId, FieldList}, IsForBin) ->
{Index - 1, ", V" ++ integer_to_list(Index) ++ StrAcc}
end,
{_, TemStr} = lists:foldr(FunHead, {FieldLen, "}) ->\n\t"}, FieldList),
case IsForBin of
true ->
HeadStr = "encode({" ++ MsgName ++ TemStr;
_ ->
HeadStr = "encodeRec({" ++ MsgName ++ TemStr
end,
HeadStr =
case IsForBin of
true ->
"encode({" ++ MsgName ++ TemStr;
_ ->
"encodeRec({" ++ MsgName ++ TemStr
end,
FunBody =
fun({FieldType, _FieldName}, {Index, PStrAcc}) ->
@ -684,7 +685,7 @@ convertDir(ProtoDir, HrlDir, ErlDir) ->
MessageId1 > MessageId2 end, SProtoList),
FunSpell =
fun({MsgName, MsgId, FieldList} = MsgInfo, {MsgHrlAcc, MsgIdAcc, MsgEncodeAcc, MsgDecodeAcc}) ->
fun({MsgName, _MsgId, FieldList} = MsgInfo, {MsgHrlAcc, _MsgIdAcc, MsgEncodeAcc, MsgDecodeAcc}) ->
%% gen hrl str
Len = erlang:length(FieldList),
{_, Len, LastFieldStr} = lists:foldr(fun genMsgHrl/2, {Len, Len, ""}, FieldList),

+ 117
- 0
test/gpb/gpb.hrl View File

@ -0,0 +1,117 @@
-ifndef(gpb_hrl).
-define(gpb_hrl, true).
-type gpb_scalar() ::
int32 | int64 | uint32 | uint64 | sint32 | sint64
| fixed32 | fixed64 | sfixed32 | sfixed64
| bool
| float | double
| string
| bytes.
-type gpb_map_key() :: % "any scalar type except floating point types and bytes"
int32 | int64 | uint32 | uint64 | sint32 | sint64
| fixed32 | fixed64 | sfixed32 | sfixed64
| bool
| string.
%% It is not possible to have maps in maps directly,
%% so this type is any gpb_field_type() except {map,K,V}.
-type gpb_map_value() ::
gpb_scalar()
| {enum,atom()}
| {msg,atom()}.
-type gpb_field_type() :: %% Erlang type Comment
int32 | int64 % integer() variable-length encoded
| uint32 | uint64 % integer() variable-length encoded
| sint32 | sint64 % integer() variable-length zig-zag encoded
| fixed32 | fixed64 % integer() always 4 | 8 bytes on wire
| sfixed32 | sfixed64 % integer() always 4 | 8 bytes on wire
| bool % true | false
| float | double % float()
| string % string() UTF-8 encoded
% | binary() iff option `strings_as_binaries'
| bytes % binary()
| {enum,atom()} % atom() the enum literal is the atom
| {msg,atom()} % record() the message name is record name
% | map() iff option `maps'
| {group,atom()} % record() name is <msg name>_<field name>
% | map() iff option `maps'
| {map,gpb_map_key(),gpb_map_value()}. % [{K,V}] | map()
%% An intermediary type temporarily used internally within gpb during parsing,
%% neither returned from gpb, nor accepted as input go gpb.
-type gpb_internal_intermediary_ref() ::
{ref, term()} |
{msg, list()} |
{group, list()} |
{enum, list()}.
-type gpb_internal_intermediary_map_ref() ::
{map, gpb_map_key(), gpb_map_value() | gpb_internal_intermediary_ref()}.
%% The following two definitions (`gpb_field' and `gpb_rpc') are to
%% avoid clashes with other code, since the `field' and `rpc' are
%% really too general names, they should have been prefixed.
%%
%% Unfortunately, they are already part of the API, so they can't
%% be changed without breaking backwards compatibility.
%% (They appear as parameters or return values for functions in `gpb'
%% in generated code.)
%%
%% In case a clash, it is possible to redefine the name locally.
%% The recommendation is to redefine them with prefix, ie to `gpb_field'
%% and `gpb_rpc', since this is what they will change to in some future.
%%
-ifdef(gpb_field_record_name).
-define(gpb_field, ?gpb_field_record_name).
-else.
-define(gpb_field, field). %% odd definition is due to backwards compatibility
-endif.
-ifdef(gpb_rpc_record_name).
-define(gpb_rpc, ?gpb_rpc_record_name).
-else.
-define(gpb_rpc, rpc). %% odd definition is due to backwards compatibility
-endif.
-record(?gpb_field, % NB: record name is (currently) `field' (not `gpb_field')!
{name :: atom()
| undefined, % temporarily in some phases
fnum :: integer()
| undefined, % temporarily in some phases
rnum :: pos_integer() % field number in the record
| undefined, % temporarily, during parsing
type :: gpb_field_type() |
gpb_internal_intermediary_ref() |
gpb_internal_intermediary_map_ref()
| undefined, % temporarily in some phases
occurrence :: 'required' | 'optional' | 'repeated'
| undefined, % temporarily in some phases
opts = [] :: [term()]
}).
-record(gpb_oneof,
{name :: atom()
| undefined, % temporarily in some phases
rnum :: pos_integer() % field number in the record
| undefined, % temporarily, during parsing
fields :: [#?gpb_field{}] % all fields have the same rnum
| undefined % temporarily in some phases
}).
-record(?gpb_rpc, % NB: record name is (currently) `rpc' (not `gpb_rpc')!
{name :: atom()
| undefined, % temporarily in some phases
input,
output,
input_stream :: boolean()
| undefined, % temporarily in some phases
output_stream :: boolean()
| undefined, % temporarily in some phases
opts :: [term()]
| undefined % temporarily in some phases
}).
-endif.

+ 2016
- 0
test/gpb/mytest.erl
File diff suppressed because it is too large
View File


+ 59
- 0
test/gpb/mytest.hrl View File

@ -0,0 +1,59 @@
%% -*- coding: utf-8 -*-
%% Automatically generated, do not edit
%% Generated by gpb_compile version 4.8.0
-ifndef(mytest).
-define(mytest, true).
-define(mytest_gpb_version, "4.8.0").
-ifndef('TEST_PB_H').
-define('TEST_PB_H', true).
-record(test,
{aa :: iodata() % = 1
}).
-endif.
-ifndef('PHONENUMBER_PB_H').
-define('PHONENUMBER_PB_H', true).
-record(phoneNumber,
{number :: mytest:test(), % = 1
type :: integer() % = 2, 32 bits
}).
-endif.
-ifndef('PERSON_PB_H').
-define('PERSON_PB_H', true).
-record(person,
{name :: iodata(), % = 1
integer :: integer(), % = 2, 32 bits
email :: iodata() | undefined, % = 3
phone = [] :: [mytest:phoneNumber()] | undefined % = 4
}).
-endif.
-ifndef('ADDRESSBOOK_PB_H').
-define('ADDRESSBOOK_PB_H', true).
-record(addressBook,
{person1 = [] :: [mytest:person()] | undefined, % = 1
others = [] :: [mytest:person()] | undefined % = 2
}).
-endif.
-ifndef('TINT32_PB_H').
-define('TINT32_PB_H', true).
-record(tint32,
{int1 :: integer(), % = 1, 32 bits
int2 :: integer(), % = 2, 32 bits
int3 :: integer(), % = 3, 32 bits
int4 :: integer(), % = 4, 32 bits
int5 :: integer(), % = 5, 32 bits
int6 :: integer(), % = 6, 32 bits
int7 :: integer(), % = 7, 32 bits
int8 :: integer(), % = 8, 32 bits
int9 :: integer(), % = 9, 32 bits
int10 :: integer() % = 10, 32 bits
}).
-endif.
-endif.

+ 33
- 0
test/gpb/mytest.proto View File

@ -0,0 +1,33 @@
message test {
required string aa = 1;
}
message phoneNumber {
required test number = 1;
required int32 type = 2;
}
message person {
required string name = 1;
required int32 integer = 2;
optional string email = 3;
repeated phoneNumber phone = 4;
}
message addressBook {
repeated person person1 = 1;
repeated person others = 2;
}
message tint32 {
required int32 int1 = 1;
required int32 int2 = 2;
required int32 int3 = 3;
required int32 int4 = 4;
required int32 int5 = 5;
required int32 int6 = 6;
required int32 int7 = 7;
required int32 int8 = 8;
required int32 int9 = 9;
required int32 int10 = 10;
}

+ 4
- 42
test/protoMsg.erl View File

@ -208,44 +208,6 @@ deRecordList(N, MsgId, MsgBin, RetList) ->
{Tuple, LeftBin} = decodeRec(MsgId, MsgBin),
deRecordList(N - 1, MsgId, LeftBin, [Tuple | RetList]).
getMsgId(test)-> 1;
getMsgId(phoneNumber)-> 2;
getMsgId(person)-> 3;
getMsgId(addressBook)-> 4;
getMsgId(union)-> 5;
getMsgId(tbool)-> 6;
getMsgId(tint8)-> 7;
getMsgId(tuint8)-> 8;
getMsgId(tint16)-> 9;
getMsgId(tuint16)-> 10;
getMsgId(tint32)-> 11;
getMsgId(tuint32)-> 12;
getMsgId(tint64)-> 13;
getMsgId(tuint64)-> 14;
getMsgId(tinteger)-> 15;
getMsgId(tnumber)-> 16;
getMsgId(tfloat)-> 17;
getMsgId(tdouble)-> 18;
getMsgId(tstring)-> 19;
getMsgId(tlistbool)-> 20;
getMsgId(tlistint8)-> 21;
getMsgId(tlistuint8)-> 22;
getMsgId(tlistint16)-> 23;
getMsgId(tlistuint16)-> 24;
getMsgId(tlistint32)-> 25;
getMsgId(tlistuint32)-> 26;
getMsgId(tlistint64)-> 27;
getMsgId(tlistuint64)-> 28;
getMsgId(tlistinteger)-> 29;
getMsgId(tlistnumber)-> 30;
getMsgId(tlistfloat)-> 31;
getMsgId(tlistdouble)-> 32;
getMsgId(tliststring)-> 33;
getMsgId(tlistunion)-> 34;
getMsgId(allType)-> 35;
getMsgId(person1)-> 1001;
getMsgId(_) -> 0.
encodeRec({test, V1}) ->
[?string(V1)];
encodeRec({phoneNumber, V1, V2}) ->
@ -277,8 +239,8 @@ encode({tint16, V1, V2}) ->
[<<9:16/big-unsigned>>, ?int16(V1), ?int16(V2)];
encode({tuint16, V1, V2}) ->
[<<10:16/big-unsigned>>, ?uint16(V1), ?uint16(V2)];
encode({tint32, V1, V2}) ->
[<<11:16/big-unsigned>>, ?int32(V1), ?int32(V2)];
encode({tint32, V1, V2, V3, V4, V5, V6, V7, V8, V9, V10}) ->
[<<11:16/big-unsigned>>, ?int32(V1), ?int32(V2), ?int32(V3), ?int32(V4), ?int32(V5), ?int32(V6), ?int32(V7), ?int32(V8), ?int32(V9), ?int32(V10)];
encode({tuint32, V1, V2}) ->
[<<12:16/big-unsigned>>, ?uint32(V1), ?uint32(V2)];
encode({tint64, V1, V2}) ->
@ -417,8 +379,8 @@ decodeBin(10, LeftBin0) ->
<<V1:16/big-unsigned, V2:16/big-unsigned, LeftBin1/binary>> = LeftBin0,
{tuint16, V1, V2};
decodeBin(11, LeftBin0) ->
<<V1:32/big-signed, V2:32/big-signed, LeftBin1/binary>> = LeftBin0,
{tint32, V1, V2};
<<V1:32/big-signed, V2:32/big-signed, V3:32/big-signed, V4:32/big-signed, V5:32/big-signed, V6:32/big-signed, V7:32/big-signed, V8:32/big-signed, V9:32/big-signed, V10:32/big-signed, LeftBin1/binary>> = LeftBin0,
{tint32, V1, V2, V3, V4, V5, V6, V7, V8, V9, V10};
decodeBin(12, LeftBin0) ->
<<V1:32/big-unsigned, V2:32/big-unsigned, LeftBin1/binary>> = LeftBin0,
{tuint32, V1, V2};

+ 8
- 0
test/protoMsg.hrl View File

@ -61,6 +61,14 @@
-record(tint32 ,{
int1 = 0 :: int32()
, int2 = 0 :: int32()
, int3 = 0 :: int32()
, int4 = 0 :: int32()
, int5 = 0 :: int32()
, int6 = 0 :: int32()
, int7 = 0 :: int32()
, int8 = 0 :: int32()
, int9 = 0 :: int32()
, int10 = 0 :: int32()
}).
-record(tuint32 ,{
int1 = 0 :: uint32()

+ 100
- 32
test/test.erl View File

@ -3,6 +3,86 @@
-include("protoMsg.hrl").
-compile(export_all).
encode_int32(N) ->
TT = #tint32{int1 = 1, int2 = -1, int3 = 128, int4 = -128, int5 = 65536,
int6 = -65536, int7 = 2100000000, int8 = -2100000000, int9 = 678665, int10 = -678665},
tt1(N, TT).
tt1(0, TT) ->
ok;
tt1(N, TT) ->
protoMsg:encode(TT),
tt1(N - 1, TT).
decode_int32(N) ->
TT = #tint32{int1 = 1, int2 = -1, int3 = 128, int4 = -128, int5 = 65536,
int6 = -65536, int7 = 2100000000, int8 = -2100000000, int9 = 678665, int10 = -678665},
Bin = protoMsg:encode(TT),
tt2(N, iolist_to_binary(Bin)).
tt2(0, Bin) ->
Bin;
tt2(N, Bin) ->
protoMsg:decode(Bin),
tt2(N - 1, Bin).
encode_addressBook(N) ->
Add = #addressBook{
person = [
#person{
name = "Alice",
id = 10000,
phone = [
#phoneNumber{number = #test{aa = "123456789"}, type = 1},
#phoneNumber{number = #test{aa = "87654321"}, type = 2}
]
},
#person{
name = "Bob",
id = 20000,
phone = [
#phoneNumber{number = #test{aa = "01234567890"}, type = 3}
]
}
]
},
tt3(N, Add).
tt3(0, Add) ->
ok;
tt3(N, Add) ->
protoMsg:encode(Add),
tt3(N - 1, Add).
decode_addressBook(N) ->
AddressBook = #addressBook{
person = [
#person{
name = "Alice",
id = 10000,
phone = [
#phoneNumber{number = #test{aa = "123456789"}, type = 1},
#phoneNumber{number = #test{aa = "87654321"}, type = 2}
]
},
#person{
name = "Bob",
id = 20000,
phone = [
#phoneNumber{number = #test{aa = "01234567890"}, type = 3}
]
}
]
},
Bin = protoMsg:encode(AddressBook),
tt4(N, iolist_to_binary(Bin)).
tt4(0, Bin) ->
Bin;
tt4(N, Bin) ->
protoMsg:decode(Bin),
tt4(N - 1, Bin).
test1() ->
protoMsg:decode(iolist_to_binary(protoMsg:encode(#tbool{bool = true}))).
@ -19,6 +99,8 @@ test32() ->
test41() ->
protoMsg:decode(iolist_to_binary(protoMsg:encode(#tint32{int1 = 12343434, int2 = -34434322}))).
test42() ->
protoMsg:decode(iolist_to_binary(protoMsg:encode(#tuint32{int1 = 432444343, int2 = 432443433}))).
@ -29,12 +111,13 @@ test52() ->
tt6(N) ->
Bin = iolist_to_binary(protoMsg:encode(#tinteger{int1 = -1, int2 = 1, int3 = 128, int4 = -128, int5 = -3244232, int6 = 432423432, int7 = -43434343434434, int8 = 432424242434})),
test6(N, Bin).
<<_MsgId:16/big, MsgBin/binary>> = Bin,
test6(N, MsgBin).
test6(0, Bin) ->
io:format("IMY******111 ~p~n", [protoMsg:decode(Bin)]);
test6(N, Bin) ->
protoMsg:decode(Bin),
protoMsg:decodeBin(15, Bin),
test6(N - 1, Bin).
tt66(N) ->
@ -48,9 +131,10 @@ test66(0, Bin) ->
io:format("IMY******111 ~p~n", [A]);
test66(N, Bin) ->
<<_MsgId:16/big, MsgBin/binary>> = Bin,
<<IntBits1:8, Int1:IntBits1/big-signed, IntBits2:8, Int2:IntBits2/big-signed, IntBits3:8, Int3:IntBits3/big-signed, IntBits4:8, Int4:IntBits4/big-signed, IntBits5:8, Int5:IntBits5/big-signed, IntBits6:8, Int6:IntBits6/big-signed, IntBits7:8, Int7:IntBits7/big-signed, IntBits8:8, Int8:IntBits8/big-signed, LeftBin/binary>> = MsgBin,
MsgRec = {tinteger, Int1, Int2, Int3, Int4, Int5, Int6, Int7, Int8},
{MsgRec,LeftBin},
%% <<IntBits1:8, Int1:IntBits1/big-signed, IntBits2:8, Int2:IntBits2/big-signed, IntBits3:8, Int3:IntBits3/big-signed, IntBits4:8, Int4:IntBits4/big-signed, IntBits5:8, Int5:IntBits5/big-signed, IntBits6:8, Int6:IntBits6/big-signed, IntBits7:8, Int7:IntBits7/big-signed, IntBits8:8, Int8:IntBits8/big-signed, LeftBin/binary>> = MsgBin,
%% {tinteger, Int1, Int2, Int3, Int4, Int5, Int6, Int7, Int8},
<<IntBits1:8, V1:IntBits1/big-signed, IntBits2:8, V2:IntBits2/big-signed, IntBits3:8, V3:IntBits3/big-signed, IntBits4:8, V4:IntBits4/big-signed, IntBits5:8, V5:IntBits5/big-signed, IntBits6:8, V6:IntBits6/big-signed, IntBits7:8, V7:IntBits7/big-signed, IntBits8:8, V8:IntBits8/big-signed, LeftBin1/binary>> = MsgBin,
{tinteger, V1, V2, V3, V4, V5, V6, V7, V8},
test66(N - 1, Bin).
tt67(N) ->
@ -335,8 +419,8 @@ tet([YY | T]) ->
ok,
tet(T).
tt1(0) ->
AddressBook = #addressBook{
ttt11(N) ->
Add = #addressBook{
person = [
#person{
name = "Alice",
@ -355,31 +439,15 @@ tt1(0) ->
}
]
},
Bin = protoMsg:encode(AddressBook);
tt1(N) ->
tt1(),
tt1(N - 1).
ttt11(N, Add).
tt1() ->
AddressBook = #addressBook{
person = [
#person{
name = "Alice",
id = 10000,
phone = [
#phoneNumber{number = #test{aa = "123456789"}, type = 1},
#phoneNumber{number = #test{aa = "87654321"}, type = 2}
]
},
#person{
name = "Bob",
id = 20000,
phone = [
#phoneNumber{number = #test{aa = "01234567890"}, type = 3}
]
}
]
},
ttt11(0, Add) ->
ok;
ttt11(N, Add) ->
protoMsg:encode(Add),
ttt11(N - 1, Add).
%%tt1(Add) ->
%"others" => [
% #{
% "name" => "Carol",
@ -391,7 +459,7 @@ tt1() ->
%]
%AddressBook = #person{name = "1232134", id = 11111,email = "aaa" ,phone = [#phoneNumber{}] },
%AddressBook = #phoneNumber{number =#test{aa = "dffsaf"},type = 12 },
Bin = protoMsg:encode(AddressBook).
%%protoMsg:encode(Add).
%ok = file:write_file("fff.bin", Bin),
%print_bin(Bin),
%Bin = protoCode:encode(AddressBook),

Loading…
Cancel
Save