RIO DE JANEIRO — Brazil’s homicide rate soared over the past two decades even as the state and the public sector greatly increased spending on public safety, Brazil’s government said Monday as it reported results of a rare study measuring the economic impact of violence in the country.

The cumulative cost of crime — including estimates of the loss of productivity and the cost of policing and incarceration — amounted to more than 4.3 percent of Brazil’s gross domestic product in 2015, the most recent year for which comprehensive data was available, according to the report.

From 1996 to 2015, the cost of violence in Brazil rose to more than $138 billion a year, from about $54 billion, a level government officials called unsustainable at a time when several Brazilian states are unable to legally raise their spending ceiling and others are broke.

The government put the total cost of violence during those two decades at $1.937 trillion.

“The numbers are striking,” said Hussein Kalout, the special secretary for strategic affairs, the division of the president’s office that conducted the study. “You can’t have a prosperous society with high crime rates.”