更新旧模型并将 运行 弃用并出现错误我已经修复了很多,这里的 tic toc 问题什么是最好的替代解决方案?

Updating an old model and running into deprecation and getting errors I have fixed a lot, tic toc problem here what is the best solution to replace?

ERROR

Calculating DraftKings baseball linueps. 3 lineups Formulation baseball_formulation Overlap = 6 Stack size = 5

LoadError: UndefVarError: tic not defined in expression starting at C:\Users\Carlos Soto\Daily-Fantasy-Baseball-Contests-in-DraftKings-master\optimize_multiple_lineups_baseball.jl:43

Stacktrace: [1] top-level scope @ C:\Users\Carlos Soto\Daily-Fantasy-Baseball-Contests-in-DraftKings-master\optimize_multiple_lineups_baseball.jl:43 [2] include(fname::String) @ Base.MainInclude .\client.jl:451 [3] top-level scope @ In[29]:1 [4] eval @ .\boot.jl:373 [inlined] [5] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String) @ Base .\loading.jl:1196

代码

This code solves for multiple baseball lineups
using DataFrames
using CSV
include(“data_cleaning.jl”)
include(“baseball_formulations.jl”) #this code has all the different formualations 

########################################### ################################################## ### ############## ################################################## ################################################ ############## ################################################## ################################################ ##############

#INPUT PARAMS

num_lineups is the total number of lineups
num_lineups = 3;

num_overlap is the maximum overlap of players between the lineups
num_overlap = 6

#number of hitters in the stack (number of consecutive hitters in the hitting order)
stack_size = 5;

#FORMULATION: formulation is the type of formulation that you would like to use.
formulation = baseball_formulation

path_pitchers = “2016-08-12 pitchers.csv”
path_hitters = “2016-08-12 hitters.csv”;

path_to_output is a string that gives the path to the csv file that will give the outputted 
results
path_to_output= string(string(formulation), “stacksize”, stack_size,“overlap”, 
num_overlap,“lineups”, num_lineups,".csv");

path_to_output_proj is a string that gives the path to the csv file that will give the 
outputted results with projected lineup points
path_to_output_proj = string(“proj_baseball_”, string(formulation), “stacksize”, 
stack_size,“overlap”, num_overlap,“lineups”, num_lineups,".csv");

path_to_output_actual is a string that gives the path to the csv file that will give the 
outputted results with projected and actual lineup points
path_to_output_actual = string(“actual_baseball_”, string(formulation), “stacksize”, 
stack_size,“overlap”, num_overlap,“lineups”, num_lineups,".csv");

#########################################################################

Running the code
println("Calculating DraftKings baseball linueps.\n “, num_lineups, " lineups\n”,"Formulation 
",formulation,
"\nOverlap = “, num_overlap,”\nStack size = ", stack_size)

tic()
create_lineups(num_lineups, num_overlap, stack_size,formulation, path_pitchers,path_hitters, 
path_to_output);
telapsed = toq();

println("\nCalculated DraftKings baseball lineups.\n\tNumber of lineups = ", num_lineups, " 
\n\tStack size = ",stack_size,
“\n\tOverlap = “, num_overlap,”\n” )

println("Took ", telapsed/60.0, " minutes to calculate “, num_lineups, " lineups”)

println(“Saving data to file “,path_to_output,”\nDK Mafia 4 life”)

#save the projected and actual points for the lineups
lineup_points_proj(path_to_output,path_hitters,path_pitchers,path_to_output_proj);
#lineup_points_actual(path_to_output,path_hitters,path_pitchers,path_to_output_actual);

这个答案的两个部分:

  1. 关于眼前的问题:tictoc removed in Julia 0.7 支持 @time 宏。所以不要写
tic()
my_function_call(arg1, arg2, ...)
toc()

你现在写

@time my_function_call(arg1, arg2, ...)
  1. 一般来说,当从旧的 Julia 版本更新代码时,建议首先验证它确实可以使用开发它的版本工作,然后再继续 version-by-version。这样,当您的代码中的某些内容在未来版本中不起作用时,您将收到弃用警告。要查看此示例,这里是 Julia 0.6.4:
julia> tic()
0x00043e524144a02b
julia> toc()
elapsed time: 2.043187801 seconds
2.043187801

这是 Julia 0.7:

julia> tic()
┌ Warning: `tic()` is deprecated, use `@time`, `@elapsed`, or calls to `time_ns()` instead.
│   caller = top-level scope at none:0
└ @ Core none:0
0x00043e951b0f07c4

julia> toc()
┌ Warning: `toc()` is deprecated, use `@time`, `@elapsed`, or calls to `time_ns()` instead.
│   caller = top-level scope at none:0
└ @ Core none:0
elapsed time: 1.73983 seconds
1.73983

现在你可能会想“哦,哇,这很烦人,因为我想更新到 1.8 版”,但好消息是 Julia 遵循 SemVer,1.0 之后的所有内容都是次要版本更新(相当比一个主要的),根据 SemVer “以向后兼容的方式添加 [s] 功能”。

0.7 是一个过渡版本,它基本上为用户准备了突破性的 1.0 版本——您可以将其视为“带有弃用警告的 1.0”。因此,让您的代码进入 post-1.0 Julia 版本的可用状态非常有帮助。

当然,这并不是说如果您打算继续使用您的代码就必须就此打住。 Julia 正在快速发展并在 1.0 和 1.8 之间取得了巨大进步,在某些情况下,您会希望更改代码以利用新功能 - 但从工作基础上做到这一点要容易得多,因此修复弃用警告在旧版本上查看是第一步。