Skip to content

Commit

Permalink
edit travis.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongwencool committed Mar 3, 2018
1 parent 06346e2 commit 3f6417d
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 22 deletions.
22 changes: 22 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
language: erlang
otp_release:
- 20.1
- 19.3
- 18.3
- 17.5
- R16B03-1
- R15B03

env:
- PATH=$HOME/.cache/rebar3/bin/:$PATH

before_script:
- curl -O -L https://s3.amazonaws.com/rebar3/rebar3
- chmod +x rebar3
- ./rebar3 update

script: "rm -rf deps ebin test/*.beam logs && ./rebar3 compile"

branches:
only:
- master
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
erlenv
erl-env
=====
[![Github Tag](https://img.shields.io/github/tag/zhongwencool/erl-env.svg)](https://github.com/zhongwencool/erl-env)
[![Build Status](https://travis-ci.org/zhongwencool/erl-env.svg?branch=master)](https://travis-ci.org/zhongwencool/erl-env)
[![license](https://img.shields.io/github/license/mashape/apistatus.svg?style=flat-square)](https://github.com/zhongwencool/erl-env)
[![Hex.pm](https://img.shields.io/hexpm/v/eenv.svg)](http://hex.pm/packages/eenv)
[![Hex.pm Downloads](https://img.shields.io/hexpm/dt/eenv.svg?style=flat-square)](https://hex.pm/packages/eenv)

## Goal
`eenv` makes retrieving configuration parameters used by application faster and more stable then *application:get_env*.
Expand Down Expand Up @@ -55,6 +60,7 @@ LogLevel = eenv:get(appname_2, log_level, error),
LogPath = eenv:get(appname_1, log_path, "log/error.log").
```
Each loaded application will generate `eenv_'AppName'.beam` to save own configuration information.

`eenv`'s code is very straightforward(lines < 200) and worth a visit.

## Quick Start
Expand Down Expand Up @@ -238,25 +244,25 @@ eenv| 206175.821| 2061758.207| 10914.20x rec |
but the problem is that it's very memory consuming(N copy data with N processes running) and difficult to update.
`dict/rec ≈ 2.50`, `map/rec ≈ 3.10`, `map/dict ≈ 1.24`.

- `eenv` and `static code beam` almost the same, depend on the clause order and test sample.
- `eenv` and `code`(static beam) almost the same, depend on the clause order and test sample.

- `eenv/app ≈ 7.20` and `eenv` cost less CPU resources than `app`.

- If CPU resources enough, `eenv` slower then `dict` about 6 times, and cost more CPU.

### Confused
- Why eenv and code time is increase? it should be constant.
- Why eenv/code time is increase? it should be constant.

It exhausts CPU resources when lots of processes running in busy circle, so time trend to increase.

- But why dict/map/rec time almost constant?

It only increase not obvious way.
Because fetch data from memory cost less CPU, and super fast(0.0x us) make it's hard to create lots of processes running at same time.
Because fetch data from memory cost very little CPU and super fast(0.0x us), it's hard to create lots of processes running at same time.
You should see increase when run `make benchmark50000`.

## ChangeLog

## License
MIT.
See the [LICENSE](https://github.com/zhongwencool/erl-env/blob/master/LICENSE) file for license rights and limitations (MIT).

28 changes: 14 additions & 14 deletions benchmark/eenv_benchmark.erl
Original file line number Diff line number Diff line change
Expand Up @@ -138,20 +138,6 @@ cleanup() ->
application:unload(ssl),
ok.

test_code() ->
Count = 10000,
MinProcNum = 100,
MaxProcNum = 1000,
io:format("~s~n", [lists:duplicate(30, $-)]),
io:format("|Process|Time/(Count*ProcNum)|~n"),
Func = fun() -> run_code(Count) end,
lists:foreach(fun(ProcNum) ->
Time = benchmark(ProcNum, Func),
io:format("|~6w | ~17.4fns| ~n", [ProcNum, Time/(Count*ProcNum)])
end, lists:seq(MinProcNum, MaxProcNum, 100)),
io:format("~s~n", [lists:duplicate(30, $-)]),
ok.

benchmark(ProcNum, Func) ->
erlang:garbage_collect(),
Pids = [begin spawn(fun() -> worker(Func) end) end|| _<- lists:seq(1, ProcNum)],
Expand Down Expand Up @@ -326,3 +312,17 @@ run_map(Count, Map) ->
#{?PAR_165 := {ok, test_val}} = Map,
#{?PAR_185 := {ok, test_val}} = Map,
run_map(Count - ?INCR, Map).

test_code() ->
Count = 10000,
MinProcNum = 100,
MaxProcNum = 1000,
io:format("~s~n", [lists:duplicate(30, $-)]),
io:format("|Process|Time/(Count*ProcNum)|~n"),
Func = fun() -> run_code(Count) end,
lists:foreach(fun(ProcNum) ->
Time = benchmark(ProcNum, Func),
io:format("|~6w | ~17.4fns| ~n", [ProcNum, Time/(Count*ProcNum)])
end, lists:seq(MinProcNum, MaxProcNum, 100)),
io:format("~s~n", [lists:duplicate(30, $-)]),
ok.
6 changes: 3 additions & 3 deletions src/eenv.app.src
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{application, eenv,
[{description, "Application ENV Manager"},
[{description, "Application Configuration Manager"},
{vsn, "0.1.0"},
{registered, []},
{applications,
[kernel, stdlib]},
{env,[]},
{modules, []},

{maintainers, []},
{maintainers, ["zhongwencool"]},
{licenses, ["MIT"]},
{links, []}
{links, [{"Github", "https://github.com/zhongwencool/erl-env"}]}
]}.

0 comments on commit 3f6417d

Please sign in to comment.