Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update profile file, add NullLogger to perf file #98

Merged
merged 1 commit into from
Jul 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion perf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import TexasHoldem
const TH = TexasHoldem
using TexasHoldem
using BenchmarkTools
using Logging

struct BotCheckCall <: AbstractAI end

Expand All @@ -11,4 +12,7 @@ TH.player_option!(game::Game, player::Player{BotCheckCall}, ::AbstractGameState,
TH.player_option!(game::Game, player::Player{BotCheckCall}, ::AbstractGameState, ::CallFold) = call!(game, player)

players() = ntuple(i->(Player(BotCheckCall(), i)), 4)
@benchmark play!(Game(players()))

@benchmark with_logger(NullLogger()) do
play!(Game(players()))
end
26 changes: 17 additions & 9 deletions profile.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Profile
using PlayingCards
using TexasHoldem
import TexasHoldem
const TH = TexasHoldem
using TexasHoldem
using BenchmarkTools
using Logging

struct BotCheckCall <: AbstractAI end

Expand All @@ -11,11 +11,19 @@ TH.player_option!(game::Game, player::Player{BotCheckCall}, ::AbstractGameState,
TH.player_option!(game::Game, player::Player{BotCheckCall}, ::AbstractGameState, ::CallAllInFold) = call!(game, player)
TH.player_option!(game::Game, player::Player{BotCheckCall}, ::AbstractGameState, ::CallFold) = call!(game, player)

function main(n_games)
players = ntuple(i->(Player(BotCheckCall(), i)), 10)
play(Game(players))
players() = ntuple(i->(Player(BotCheckCall(), i)), 4)

with_logger(NullLogger()) do
play!(Game(players()))
end

using Profile
@profile begin
for k in 1:100
with_logger(NullLogger()) do
play!(Game(players()))
end
end
end

main(1) # Compile first:
@profile main(10) # time
# Profile.print()
Profile.print(format=:flat, sortedby=:count)