Change counting time function

pull/8512/head
Nikita Pozdniakov 1 year ago
parent 2f4db2e9aa
commit 6896b092df
No known key found for this signature in database
GPG Key ID: F344106F9804FE5F
  1. 32
      apps/explorer/lib/explorer/chain/address/counters.ex
  2. 3
      docker-compose/envs/common-blockscout.env

@ -341,7 +341,7 @@ defmodule Explorer.Chain.Address.Counters do
end
end)
start = Time.utc_now()
start = System.monotonic_time()
validations_count_task =
configure_task(
@ -362,9 +362,10 @@ defmodule Explorer.Chain.Address.Counters do
|> limit(@counters_limit)
|> select_repo(options).all()
Logger.info(
"Time consumed for transactions_from_count_task for #{address_hash} is #{Time.diff(Time.utc_now(), start, :millisecond)}ms"
)
stop = System.monotonic_time()
diff = System.convert_time_unit(stop - start, :native, :millisecond)
Logger.info("Time consumed for transactions_from_count_task for #{address_hash} is #{diff}ms")
AddressesTabsCounters.save_txs_counter_progress(address_hash, %{txs_types: [:txs_from], txs_from: result})
AddressesTabsCounters.drop_task(:txs_from, address_hash)
@ -382,9 +383,10 @@ defmodule Explorer.Chain.Address.Counters do
|> limit(@counters_limit)
|> select_repo(options).all()
Logger.info(
"Time consumed for transactions_to_count_task for #{address_hash} is #{Time.diff(Time.utc_now(), start, :millisecond)}ms"
)
stop = System.monotonic_time()
diff = System.convert_time_unit(stop - start, :native, :millisecond)
Logger.info("Time consumed for transactions_to_count_task for #{address_hash} is #{diff}ms")
AddressesTabsCounters.save_txs_counter_progress(address_hash, %{txs_types: [:txs_to], txs_to: result})
AddressesTabsCounters.drop_task(:txs_to, address_hash)
@ -402,9 +404,10 @@ defmodule Explorer.Chain.Address.Counters do
|> limit(@counters_limit)
|> select_repo(options).all()
Logger.info(
"Time consumed for transactions_created_contract_count_task for #{address_hash} is #{Time.diff(Time.utc_now(), start, :millisecond)}ms"
)
stop = System.monotonic_time()
diff = System.convert_time_unit(stop - start, :native, :millisecond)
Logger.info("Time consumed for transactions_created_contract_count_task for #{address_hash} is #{diff}ms")
AddressesTabsCounters.save_txs_counter_progress(address_hash, %{
txs_types: [:txs_contract],
@ -525,7 +528,7 @@ defmodule Explorer.Chain.Address.Counters do
defp configure_task(counter_type, cache, query, address_hash, options) do
address_hash = to_string(address_hash)
start = Time.utc_now()
start = System.monotonic_time()
run_or_ignore(cache[counter_type], counter_type, address_hash, fn ->
result =
@ -533,9 +536,10 @@ defmodule Explorer.Chain.Address.Counters do
|> limit(@counters_limit)
|> select_repo(options).aggregate(:count)
Logger.info(
"Time consumed for #{counter_type} counter task for #{address_hash} is #{Time.diff(Time.utc_now(), start, :millisecond)}ms"
)
stop = System.monotonic_time()
diff = System.convert_time_unit(stop - start, :native, :millisecond)
Logger.info("Time consumed for #{counter_type} counter task for #{address_hash} is #{diff}ms")
AddressesTabsCounters.set_counter(counter_type, address_hash, result)
AddressesTabsCounters.drop_task(counter_type, address_hash)

@ -240,4 +240,5 @@ EIP_1559_ELASTICITY_MULTIPLIER=2
# TOKEN_INSTANCE_OWNER_MIGRATION_CONCURRENCY=5
# TOKEN_INSTANCE_OWNER_MIGRATION_BATCH_SIZE=50
# IPFS_GATEWAY_URL=
API_V2_ENABLED=true
API_V2_ENABLED=true
# ADDRESSES_TABS_COUNTERS_TTL=10m
Loading…
Cancel
Save